Documentation ¶
Overview ¶
Package gotwilio is a library for interacting with http://www.twilio.com/ API.
Package gotwilio is a library for interacting with http://www.twilio.com/ API.
Package gotwilio is a library for interacting with http://www.twilio.com/ API.
Package gotwilio is a library for interacting with http://www.twilio.com/ API.
Index ¶
- Constants
- Variables
- func DecodeWebhook(data url.Values, out interface{}) error
- type AccessToken
- type AlphaSender
- type AlphaSenderList
- type CallbackParameters
- type CopilotParams
- type CopilotService
- func (c *CopilotService) AddAlphaSenderID(id string, twilio *Twilio) (alphaSender *AlphaSender, exception *Exception, err error)
- func (c *CopilotService) AddPhoneNumber(sid string, twilio *Twilio) (phoneNumber *PhoneNumber, exception *Exception, err error)
- func (c *CopilotService) DeleteAlphaSenderID(sid string, twilio *Twilio) (exception *Exception, err error)
- func (c *CopilotService) DeletePhoneNumber(sid string, twilio *Twilio) (exception *Exception, err error)
- func (l *CopilotService) FetchAlphaSender(twilio *Twilio) (alphaSender *AlphaSender, exception *Exception, err error)
- type CopilotServiceList
- type Country
- type CreateCopilotServiceOptions
- type CreateNotifyServiceOptions
- type Exception
- type FaxBase
- type FaxMediaResource
- type FaxResource
- type FaxResourcesList
- type Grant
- type IncomingPhoneNumber
- type IncomingPhoneNumbers
- type Interaction
- type InteractionData
- type InteractionList
- type Links
- type ListResources
- type ListVideoReponse
- type ListVideoRoomOptions
- type MediaRegion
- type Meta
- type NotifyLinks
- type NotifyService
- type NumberCapability
- type OutboundSMSPrice
- type Participant
- type ParticipantList
- type ParticipantRequest
- type PhoneNumber
- type Price
- type PricingList
- type PricingResponse
- type ProxyCallbackWebhook
- type ProxyInterceptCallbackWebhook
- type ProxyMessage
- type ProxyOutOfSessionCallbackWebhook
- type ProxyService
- type ProxyServiceRequest
- type ProxySession
- func (session *ProxySession) AddParticipant(req ParticipantRequest) (response Participant, exception *Exception, err error)
- func (session *ProxySession) CreateInteraction(participantSid string, msg ProxyMessage) (response Interaction, exception *Exception, err error)
- func (session *ProxySession) DeleteParticipant(participantID string) (exception *Exception, err error)
- func (session *ProxySession) GetInteractions() (response InteractionList, exception *Exception, err error)
- func (session *ProxySession) GetParticipant(participantID string) (response Participant, exception *Exception, err error)
- func (session *ProxySession) ListParticipants() (response []Participant, exception *Exception, err error)
- type ProxySessionRequest
- type SmsResponse
- type Twilio
- func (twilio *Twilio) AddPhoneNumber()
- func (twilio *Twilio) CallWithApplicationCallbacks(from, to, applicationSid string) (*VoiceResponse, *Exception, error)
- func (twilio *Twilio) CallWithUrlCallbacks(from, to string, callbackParameters *CallbackParameters) (*VoiceResponse, *Exception, error)
- func (t *Twilio) CancelFax(faxSid string) (*Exception, error)
- func (twilio *Twilio) CheckRequestSignature(r *http.Request, baseURL string) (bool, error)
- func (twilio *Twilio) CreateCopilotService(options *CreateCopilotServiceOptions) (copilotResponse *CopilotService, exception *Exception, err error)
- func (twilio *Twilio) CreateNotifyService(options *CreateNotifyServiceOptions) (notifyService *NotifyService, exception *Exception, err error)
- func (twilio *Twilio) CreateVideoRoom(options *createRoomOptions) (videoResponse *VideoResponse, exception *Exception, err error)
- func (twilio *Twilio) DeleteCopilotService(sid string) (exception *Exception, err error)
- func (t *Twilio) DeleteFax(faxSid string) (*Exception, error)
- func (twilio *Twilio) DeleteNotifyService(sid string) (exception *Exception, err error)
- func (twilio *Twilio) DeleteProxyService(sid string) (exception *Exception, err error)
- func (twilio *Twilio) DeleteProxySession(serviceID, sessionID string) (exception *Exception, err error)
- func (twilio *Twilio) DeleteResource(servicesUrl string) (exception *Exception, err error)
- func (twilio *Twilio) EndVideoRoom(nameOrSid string) (videoResponse *VideoResponse, exception *Exception, err error)
- func (twilio *Twilio) GenerateSignature(url string, form url.Values) ([]byte, error)
- func (twilio *Twilio) GetCall(sid string) (*VoiceResponse, *Exception, error)
- func (twilio *Twilio) GetCopilotService(sid string) (copilotResponse *CopilotService, exception *Exception, err error)
- func (twilio *Twilio) GetCopilotServices() (copilotServiceList *CopilotServiceList, exception *Exception, err error)
- func (twilio *Twilio) GetCountriesPricing() (pricingList *PricingList, exception *Exception, err error)
- func (t *Twilio) GetFax(faxSid string) (*FaxResource, *Exception, error)
- func (t *Twilio) GetFaxes(to, from, createdOnOrBefore, createdAfter string) ([]*FaxResource, *Exception, error)
- func (twilio *Twilio) GetPhoneNumbers() (incomingPhoneNumbers *IncomingPhoneNumbers, exception *Exception, err error)
- func (twilio *Twilio) GetPricing(countryISO string) (pricingResponse *PricingResponse, exception *Exception, err error)
- func (twilio *Twilio) GetProxyService(sid string) (response *ProxyService, exception *Exception, err error)
- func (twilio *Twilio) GetProxySession(serviceID, sessionID string) (response *ProxySession, exception *Exception, err error)
- func (twilio *Twilio) GetSMS(sid string) (smsResponse *SmsResponse, exception *Exception, err error)
- func (twilio *Twilio) GetServicesWithAlphaSenders() (copilotServiceList *CopilotServiceList, exception *Exception, err error)
- func (twilio *Twilio) GetVideoRoom(nameOrSid string) (videoResponse *VideoResponse, exception *Exception, err error)
- func (twilio *Twilio) ListVideoRooms(options *ListVideoRoomOptions) (videoResponse *ListVideoReponse, exception *Exception, err error)
- func (twilio *Twilio) NewAccessToken() *AccessToken
- func (twilio *Twilio) NewProxyService(service ProxyServiceRequest) (response *ProxyService, exception *Exception, err error)
- func (twilio *Twilio) NewProxySession(serviceID string, req ProxySessionRequest) (response *ProxySession, exception *Exception, err error)
- func (t *Twilio) SendFax(to, from, mediaUrl, quality, statusCallback string, storeMedia bool) (*FaxResource, *Exception, error)
- func (twilio *Twilio) SendMMS(from, to, body, mediaUrl, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
- func (twilio *Twilio) SendSMS(from, to, body, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
- func (twilio *Twilio) SendSMSWithCopilot(params *CopilotParams) (smsResponse *SmsResponse, exception *Exception, err error)
- func (twilio *Twilio) UpdateNotifyService(serviceSID string, options *CreateNotifyServiceOptions) (notifyService *NotifyService, exception *Exception, err error)
- func (twilio *Twilio) UpdateProxyService(sid string, service ProxyServiceRequest) (response *ProxyService, exception *Exception, err error)
- func (twilio *Twilio) UpdateProxySession(serviceID, sessionID string, req ProxySessionRequest) (response *ProxySession, exception *Exception, err error)
- func (twilio *Twilio) WithAPIKey(apiKeySid string, apiKeySecret string) *Twilio
- type VideoCodecs
- type VideoGrant
- type VideoResponse
- type VideoRoomType
- type VideoStatus
- type VoiceResponse
Constants ¶
const ProxyBaseUrl = "https://proxy.twilio.com/v1"
Variables ¶
var DefaultVideoRoomOptions = &createRoomOptions{ EnableTurn: true, MaxParticipants: 10, MediaRegion: USEastCoast, RecordParticipantsOnConnect: false, StatusCallback: "", StatusCallbackMethod: http.MethodPost, Type: Group, UniqueName: "", VideoCodecs: []VideoCodecs{H264}, }
DefaultVideoRoomOptions are the default options for creating a room.
Functions ¶
func DecodeWebhook ¶
Types ¶
type AccessToken ¶
type AccessToken struct { AccountSid string APIKeySid string APIKeySecret string NotBefore time.Time ExpiresAt time.Time Grants []Grant Identity string }
AccessToken holds everything required to create authenticate the client SDKs. See https://www.twilio.com/docs/iam/access-tokens for further details.
func (*AccessToken) AddGrant ¶
func (a *AccessToken) AddGrant(grant Grant) *AccessToken
AddGrant adds a given Grant to the Access Token.
func (*AccessToken) ToJWT ¶
func (a *AccessToken) ToJWT() (string, error)
ToJWT creates a JSON Web Token from the Access Token to use in the Client SDKs. See https://en.wikipedia.org/wiki/JSON_Web_Token for the standard format.
type AlphaSender ¶
type AlphaSender struct { Sid string `json:"sid"` AccountSid string `json:"account_sid"` ServiceSid string `json:"service_sid"` DateCreated string `json:"date_created"` DateUpdated string `json:"date_updated"` AlphaSender string `json:"alpha_sender"` Capabilities []string `json:"capabilities"` Url string `json:"url"` }
type AlphaSenderList ¶
type AlphaSenderList struct { Meta Meta `json:"meta"` AlphaSenders []AlphaSender `json:"alpha_senders"` }
type CallbackParameters ¶
type CallbackParameters struct { Url string // Required Method string // Optional FallbackUrl string // Optional FallbackMethod string // Optional StatusCallback string // Optional StatusCallbackMethod string // Optional StatusCallbackEvent []string // Optional SendDigits string // Optional IfMachine string // False, Continue or Hangup; http://www.twilio.com/docs/errors/21207 Timeout int // Optional Record bool // Optional RecordingChannels string // Optional RecordingStatusCallback string // Optional RecordingStatusCallbackMethod string // Optional MachineDetection string // Optional MachineDetectionTimeout int // Optional }
These are the paramters to use when you want Twilio to use callback urls. See http://www.twilio.com/docs/api/rest/making-calls for more info.
func NewCallbackParameters ¶
func NewCallbackParameters(url string) *CallbackParameters
Returns a CallbackParameters type with the specified url and CallbackParameters.Timeout set to 60.
type CopilotParams ¶
type CopilotService ¶
type CopilotService struct { AccountSID string `json:"account_sid"` SID string `json:"sid"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` FriendlyName string `json:"friendly_name"` InboundRequestURL string `json:"inbound_request_url"` InboundMethod string `json:"inbound_method"` FallbackURL string `json:"fallback_url"` FallbackMethod string `json:"fallback_method"` StatusCallback string `json:"status_callback"` StickySender bool `json:"sticky_sender"` SmartEncoding bool `json:"smart_encoding"` MMSConverter bool `json:"mms_converter"` FallbackToLongCode bool `json:"fallback_to_long_code"` ScanMessageContent string `json:"scan_message_content"` AreaCodeGeomatch bool `json:"area_code_geomatch"` ValidityPeriod int `json:"validity_period"` SynchronousValidation bool `json:"synchronous_validation"` Links Links `json:"links"` URL string `json:"url"` PhoneNumbers []PhoneNumber `json:"phone_numbers"` AlphaSender *AlphaSender }
func (*CopilotService) AddAlphaSenderID ¶
func (c *CopilotService) AddAlphaSenderID(id string, twilio *Twilio) (alphaSender *AlphaSender, exception *Exception, err error)
func (*CopilotService) AddPhoneNumber ¶
func (c *CopilotService) AddPhoneNumber(sid string, twilio *Twilio) (phoneNumber *PhoneNumber, exception *Exception, err error)
func (*CopilotService) DeleteAlphaSenderID ¶
func (c *CopilotService) DeleteAlphaSenderID(sid string, twilio *Twilio) (exception *Exception, err error)
func (*CopilotService) DeletePhoneNumber ¶
func (c *CopilotService) DeletePhoneNumber(sid string, twilio *Twilio) (exception *Exception, err error)
func (*CopilotService) FetchAlphaSender ¶
func (l *CopilotService) FetchAlphaSender(twilio *Twilio) (alphaSender *AlphaSender, exception *Exception, err error)
type CopilotServiceList ¶
type CopilotServiceList struct { Meta Meta `json:"meta"` Services []CopilotService `json:"services"` }
type CreateCopilotServiceOptions ¶
type CreateCopilotServiceOptions struct { FriendlyName string `json:"FriendlyName"` AreaCodeGeomatch bool `json:"AreCodeGeomatch"` FallbackMethod string `json:"FallbackMethod"` FallbackToLongCode bool `json:"FallbackToLongCode"` FallbackUrl string `json:"FallbackUrl"` InboundMethod string `json:"InboundMethod"` InboundRequestUrl string `json:"InboundRequestUrl"` MmsConverter bool `json:"MmsConverter"` SmartEncoding bool `json:"SmartEncoding"` StatusCallback string `json:"StatusCallback"` StickySender bool `json:"StickySender"` ValidityPeriod int `json:"ValidityPeriod"` }
type CreateNotifyServiceOptions ¶
type CreateNotifyServiceOptions struct { FriendlyName string `json:"friendly_name"` ApnCredentialSID string `json:"apn_credential_sid"` GcmCredentialSID string `json:"gcm_credential_sid"` MessagingServiceSid string `json:"messaging_service_sid"` FacebookMessengerPageId string `json:"facebook_messenger_page_id"` DefaultApnNotificationProtocolVersion string `json:"default_apn_notification_protocol_version"` DefaultGcmNotificationProtocolVersion string `json:"default_gcm_notification_protocol_version"` FcmCredentialSid string `json:"fcm_default_sid"` DefaultFcmNotificationProtocolVersion string `json:"default_fcm_notification_protocol_version"` }
type Exception ¶
type Exception struct { Status int `json:"status"` // HTTP specific error code Message string `json:"message"` // HTTP error message Code int `json:"code"` // Twilio specific error code MoreInfo string `json:"more_info"` // Additional info from Twilio }
Exception is a representation of a twilio exception.
type FaxBase ¶
type FaxBase struct { Sid string `json:"sid"` AccountSid string `json:"account_sid"` DateCreated string `json:"date_created"` DateUpdated string `json:"date_updated"` }
func (*FaxBase) DateCreatedAsTime ¶
Returns FaxBase.DateCreated as a time.Time object instead of a string.
type FaxMediaResource ¶
type FaxResource ¶
type FaxResource struct { FaxBase From string `json:"from"` To string `json:"to"` Direction string `json:"direction"` NumPages uint `json:"num_pages,string"` Duration uint `json:"duration,string"` MediaSid string `json:"media_sid"` MediaUrl string `json:"media_url"` Status string `json:"status"` Quality string `json:"quality"` ApiVersion string `json:"api_version"` Price *string `json:"price,omitempty"` PriceUnit *string `json:"price_unit,omitempty"` }
type FaxResourcesList ¶
type FaxResourcesList struct { ListResources Faxes []*FaxResource `json:"faxes"` }
type Grant ¶
type Grant interface {
// contains filtered or unexported methods
}
Grant is a perimssion given to the Access Token. Types include Chat, Video etc.
type IncomingPhoneNumber ¶
type IncomingPhoneNumber struct { AccountSid string `json:"account_sid"` Sid string `json:"sid"` PhoneNumber string `json:"phone_number"` FriendlyName string `json:"friendly_name"` DateCreated string `json:"date_created"` AddressRequirements string `json:"address_requirements"` APIVersion string `json:"api_version"` Beta bool `json:"beta"` Capabilities *NumberCapability `json:"capabilities"` DateUpdated string `json:"date_updated"` EmergencyAddressSid string `json:"emergency_address_sid"` EmergencyStatus string `json:"emergency_status"` SMSApplicationSid string `json:"sms_application_sid"` SMSFallbackMethod string `json:"sms_fallback_method"` SMSFallbackURL string `json:"sms_fallback_url"` SMSMethod string `json:"sms_method"` SMSURL string `json:"sms_url"` StatusCallback string `json:"status_callback"` StatusCallbackMethod string `json:"status_callback_method"` TrunkSid string `json:"trunk_sid"` URI string `json:"uri"` VoiceApplicationSid string `json:"voice_application_sid"` VoiceCallerIDLookup bool `json:"voice_caller_id_lookup"` VoiceFallbackMethod string `json:"voice_fallback_method"` VoiceFallbackURL string `json:"voice_fallback_url"` VoiceMethod string `json:"voice_method"` VoiceURL string `json:"voice_url"` }
type IncomingPhoneNumbers ¶
type IncomingPhoneNumbers struct { Page int `json:"page"` PageSize int `json:"page_size"` IncomingPhoneNumbers []IncomingPhoneNumber `json:"incoming_phone_numbers"` }
type Interaction ¶
type Interaction struct { InboundResourceStatus string `json:"inbound_resource_status"` InboundResourceSid string `json:"inbound_resource_sid"` OutboundResourceStatus string `json:"outbound_resource_status"` OutboundResourceSid string `json:"outbound_resource_sid"` InboundResourceURL string `json:"inbound_resource_url"` Type string `json:"type"` AccountSid string `json:"account_sid"` OutboundResourceType string `json:"outbound_resource_type"` DateCreated time.Time `json:"date_created"` InboundResourceType string `json:"inbound_resource_type"` URL string `json:"url"` DateUpdated time.Time `json:"date_updated"` Sid string `json:"sid"` OutboundParticipantSid string `json:"outbound_participant_sid"` OutboundResourceURL string `json:"outbound_resource_url"` SessionSid string `json:"session_sid"` ServiceSid string `json:"service_sid"` Data string `json:"data"` InboundParticipantSid string `json:"inbound_participant_sid"` }
type InteractionData ¶
type InteractionData struct {
Body string `json:"body"`
}
type InteractionList ¶
type InteractionList struct { Meta Meta `json:"meta"` Interactions []Interaction `json:"interactions"` }
type ListResources ¶
type ListResources struct { Uri string `json:"uri"` FirstPageUri string `json:"first_page_uri"` NextPageUri string `json:"next_page_uri"` PreviousPageUri string `json:"previous_page_uri"` Page uint `json:"page"` PageSize uint `json:"page_size"` Faxes []*FaxResource `json:"faxes"` Messages []*SmsResponse `json:"messages"` // contains filtered or unexported fields }
ListResources contains Twilio paging information. See https://www.twilio.com/docs/usage/twilios-response#response-formats-list-paging-information
type ListVideoReponse ¶
type ListVideoReponse struct { Rooms []*VideoResponse `json:"rooms"` Meta struct { Page int64 `json:"page"` PageSize int64 `json:"page_size"` FirstPageUrl string `json:"first_page_url"` PreviousPageUrl string `json:"previous_page_url"` NextPageUrl string `json:"next_page_url"` Url string `json:"url"` Key string `json:"key"` } `json:"meta"` }
ListVideoResponse is returned when listing rooms
type ListVideoRoomOptions ¶
type ListVideoRoomOptions struct { DateCreatedAfter time.Time `json:"DateCreatedAfter"` DateCreatedBefore time.Time `json:"DateCreatedBefore"` Status VideoStatus `json:"Status"` UniqueName string `json:"EnableUniqueNameTurn"` }
ListVideoRoomOptions are the options to query for a list of video rooms.
type MediaRegion ¶
type MediaRegion string
MediaRegion is the locations of Twilio's TURN servers
const ( Australia MediaRegion = "au1" Brazil MediaRegion = "br1" Germany MediaRegion = "de1" Ireland MediaRegion = "ie1" India MediaRegion = "in1" Japan MediaRegion = "jp1" Singapore MediaRegion = "sg1" USEastCoast MediaRegion = "us1" USWestCoast MediaRegion = "us2" )
type NotifyLinks ¶
type NotifyService ¶
type NotifyService struct { SID string `json:"sid"` AccountSID string `json:"account_sid"` FriendlyName string `json:"friendly_name"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` ApnCredentialSID string `json:"apn_credential_sid"` GcmCredentialSID string `json:"gcm_credential_sid"` FcmCredentialSID string `json:"fcm_credential_sid"` MessageServiceSID string `json:"message_service_sid"` FacebookMessengerPageId string `json:"facebook_messenger_page_id"` DefaultApnNotificationProtocolVersion string `json:"default_apn_notification_protocol_version"` DefaultGcmNotificationProtocolVersion string `json:"default_gcm_notification_protocol_version"` DefaultFcmNotificationProtocolVersion string `json:"default_fcm_notification_protocol_version"` LogEnabled bool `json:"log_enabled"` URL string `json:"url"` Links NotifyLinks `json:"links"` AlexaSkillId string `json:"alexa_skill_id"` DefaultAlexaNotificationProtocolVersion string `json:"default_alexa_notification_protocol_version"` }
type NumberCapability ¶
type OutboundSMSPrice ¶
type Participant ¶
type Participant struct { Sid string `json:"sid"` Identifier string `json:"identifier"` DateUpdated time.Time `json:"date_updated"` FriendlyName interface{} `json:"friendly_name"` DateDeleted interface{} `json:"date_deleted"` AccountSid string `json:"account_sid"` URL string `json:"url"` ProxyIdentifier string `json:"proxy_identifier"` ProxyIdentifierSid string `json:"proxy_identifier_sid"` DateCreated time.Time `json:"date_created"` ParticipantSid string `json:"Participant_sid"` ServiceSid string `json:"service_sid"` Links struct { MessageInteractions string `json:"message_interactions"` } `json:"links"` }
type ParticipantList ¶
type ParticipantList struct { Participants []Participant `json:"participants"` Meta Meta `json:"meta"` }
type ParticipantRequest ¶
type PhoneNumber ¶
type PhoneNumber struct { SID string `json:"sid"` AccountSID string `json:"account_sid"` ServiceSID string `json:"service_sid"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` PhoneNumber string `json:"phone_number"` CountryCode string `json:"country_code"` Capabilities []string `json:"capabilities"` URL string `json:"url"` PhoneNumberSID string `json:"phone_number_sid"` }
type PricingList ¶
type PricingResponse ¶
type ProxyCallbackWebhook ¶
type ProxyCallbackWebhook struct { OutboundResourceStatus string `form:"outboundResourceStatus"` OutboundResourceType string `form:"outboundResourceType"` InteractionDateUpdated time.Time `form:"interactionDateUpdated"` InteractionData string `form:"interactionData"` InteractionDateCreated time.Time `form:"interactionDateCreated"` InboundResourceURL string `form:"inboundResourceUrl"` InteractionServiceSid string `form:"interactionServiceSid"` OutboundParticipantSid string `form:"outboundParticipantSid"` InteractionType string `form:"interactionType"` InteractionAccountSid string `form:"interactionAccountSid"` InboundParticipantSid string `form:"inboundParticipantSid"` InboundResourceStatus string `form:"inboundResourceStatus"` OutboundResourceSid string `form:"outboundResourceSid"` OutboundResourceURL string `form:"outboundResourceUrl"` InboundResourceType string `form:"inboundResourceType"` InboundResourceSid string `form:"inboundResourceSid"` InteractionSessionSid string `form:"interactionSessionSid"` InteractionSid string `form:"interactionSid"` }
https://www.twilio.com/docs/proxy/api/proxy-webhooks#callbackurl These webhooks are fired for each new interaction and are informational only.
func (ProxyCallbackWebhook) GetInteractionData ¶
func (p ProxyCallbackWebhook) GetInteractionData() (InteractionData, error)
type ProxyInterceptCallbackWebhook ¶
type ProxyInterceptCallbackWebhook struct { InteractionDateUpdated time.Time `form:"interactionDateUpdated"` InteractionData string `form:"interactionData"` InteractionDateCreated time.Time `form:"interactionDateCreated"` InboundResourceURL string `form:"inboundResourceUrl"` InteractionServiceSid string `form:"interactionServiceSid"` InteractionType string `form:"interactionType"` InteractionAccountSid string `form:"interactionAccountSid"` InboundParticipantSid string `form:"inboundParticipantSid"` InboundResourceStatus string `form:"inboundResourceStatus"` InboundResourceType string `form:"inboundResourceType"` InboundResourceSid string `form:"inboundResourceSid"` InteractionSessionSid string `form:"interactionSessionSid"` InteractionSid string `form:"interactionSid"` }
https://www.twilio.com/docs/proxy/api/proxy-webhooks#interceptcallbackurl Fires on each interaction. If responded to with a 403 to this webhook we will abort/block the interaction. Any other status or timeout the interaction continues
func (ProxyInterceptCallbackWebhook) GetInteractionData ¶
func (p ProxyInterceptCallbackWebhook) GetInteractionData() (InteractionData, error)
type ProxyMessage ¶
type ProxyOutOfSessionCallbackWebhook ¶
type ProxyOutOfSessionCallbackWebhook struct { AccountSid string `form:"AccountSid"` SessionUniqueName string `form:"sessionUniqueName"` SessionAccountSid string `form:"sessionAccountSid"` SessionServiceSid string `form:"sessionServiceSid"` SessionSid string `form:"sessionSid"` SessionStatus string `form:"sessionStatus"` SessionMode string `form:"sessionMode"` SessionDateCreated time.Time `form:"sessionDateCreated"` SessionDateStarted time.Time `form:"sessionDateStarted"` SessionDateUpdated time.Time `form:"sessionDateUpdated"` SessionDateEnded time.Time `form:"sessionDateEnded"` SessionDateLastInteraction time.Time `form:"sessionDateLastInteraction"` SessionClosedReason string `form:"sessionClosedReason"` TTL string `form:"ttl"` // SMS Specific Body string `form:"Body"` SmsSid string `form:"SmsSid"` MessageSid string `form:"MessageSid"` NumMedia string `form:"NumMedia"` NumSegments string `form:"NumSegments"` SmsStatus string `form:"SmsStatus"` SmsMessageSid string `form:"SmsMessageSid"` To string `form:"To"` ToCity string `form:"ToCity"` ToState string `form:"ToState"` ToZip string `form:"ToZip"` ToCountry string `form:"ToCountry"` From string `form:"From"` FromCity string `form:"FromCity"` FromState string `form:"FromState"` FromZip string `form:"FromZip"` FromCountry string `form:"FromCountry"` InboundParticipantSid string `form:"inboundParticipantSid"` InboundParticipantIdentifier string `form:"inboundParticipantIdentifier"` InboundParticipantFriendlyName string `form:"inboundParticipantFriendlyName"` InboundParticipantProxyIdentifier string `form:"inboundParticipantProxyIdentifier"` InboundParticipantProxyIdentifierSid string `form:"inboundParticipantProxyIdentifierSid"` InboundParticipantAccountSid string `form:"inboundParticipantAccountSid"` InboundParticipantServiceSid string `form:"inboundParticipantServiceSid"` InboundParticipantSessionSid string `form:"inboundParticipantSessionSid"` InboundParticipantDateCreated time.Time `form:"inboundParticipantDateCreated"` InboundParticipantDateUpdated time.Time `form:"inboundParticipantDateUpdated"` OutboundParticipantSid string `form:"outboundParticipantSid"` OutboundParticipantIdentifier string `form:"outboundParticipantIdentifier"` OutboundParticipantFriendlyName string `form:"outboundParticipantFriendlyName"` OutboundParticipantProxyIdentifier string `form:"outboundParticipantProxyIdentifier"` OutboundParticipantProxyIdentifierSid string `form:"outboundParticipantProxyIdentifierSid"` OutboundParticipantAccountSid string `form:"outboundParticipantAccountSid"` OutboundParticipantServiceSid string `form:"outboundParticipantServiceSid"` OutboundParticipantSessionSid string `form:"outboundParticipantSessionSid"` OutboundParticipantDateCreated time.Time `form:"outboundParticipantDateCreated"` OutboundParticipantDateUpdated time.Time `form:"outboundParticipantDateUpdated"` CallSid string `form:"CallSid"` CallStatus string `form:"CallStatus"` Caller string `form:"Caller"` CallerCity string `form:"CallerCity"` CallerState string `form:"CallerState"` CallerZip string `form:"CallerZip"` CallerCountry string `form:"CallerCountry"` Called string `form:"Called"` CalledCity string `form:"CalledCity"` CalledState string `form:"CalledState"` CalledZip string `form:"CalledZip"` CalledCountry string `form:"CalledCountry"` Direction string `form:"Direction"` AddOns string `form:"AddOns"` APIVersion string `form:"ApiVersion"` }
https://www.twilio.com/docs/proxy/api/proxy-webhooks#outofsessioncallbackurl A URL to send webhooks to when an action (inbound call or SMS) occurs where there is no session or a closed session. If your server (or a Twilio function) responds with valid TwiML, this will be processed. This means it is possible to e.g. play a message for a call, send an automated text message response, or redirect a call to another number.
type ProxyService ¶
type ProxyService struct { Sid string `json:"sid"` UniqueName string `json:"unique_name"` AccountSid string `json:"account_sid"` CallbackURL string `json:"callback_url"` DefaultTTL int `json:"default_ttl"` NumberSelectionBehavior string `json:"number_selection_behavior"` GeoMatchLevel string `json:"geo_match_level"` InterceptCallbackURL interface{} `json:"intercept_callback_url"` OutOfSessionCallbackURL interface{} `json:"out_of_session_callback_url"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` URL string `json:"url"` Links struct { PhoneNumbers string `json:"phone_numbers"` ShortCodes string `json:"short_codes"` Sessions string `json:"sessions"` } `json:"links"` }
type ProxyServiceRequest ¶
type ProxyServiceRequest struct { UniqueName string // optional CallbackURL string // optional OutOfSessionCallbackURL string // optional InterceptCallbackURL string // optional GeoMatchLevel string // Default: country Options: country, area-code, extended-area-code optional NumberSelectionBehavior string // Default: prefer-sticky Options: prefer-sticky, avoid-sticky optional DefaultTtl int // (seconds) Default: 0 optional }
type ProxySession ¶
type ProxySession struct { Sid string `json:"sid"` Status string `json:"status"` UniqueName string `json:"unique_name"` ClosedReason interface{} `json:"closed_reason"` DateEnded interface{} `json:"date_ended"` TTL int `json:"ttl"` DateExpiry interface{} `json:"date_expiry"` AccountSid string `json:"account_sid"` DateUpdated time.Time `json:"date_updated"` Mode string `json:"mode"` DateLastInteraction interface{} `json:"date_last_interaction"` URL string `json:"url"` DateCreated time.Time `json:"date_created"` DateStarted time.Time `json:"date_started"` ServiceSid string `json:"service_sid"` Links struct { Participants string `json:"participants"` Interactions string `json:"interactions"` } `json:"links"` // contains filtered or unexported fields }
func (*ProxySession) AddParticipant ¶
func (session *ProxySession) AddParticipant(req ParticipantRequest) (response Participant, exception *Exception, err error)
Add Participant to Session
func (*ProxySession) CreateInteraction ¶
func (session *ProxySession) CreateInteraction(participantSid string, msg ProxyMessage) (response Interaction, exception *Exception, err error)
func (*ProxySession) DeleteParticipant ¶
func (session *ProxySession) DeleteParticipant(participantID string) (exception *Exception, err error)
func (*ProxySession) GetInteractions ¶
func (session *ProxySession) GetInteractions() (response InteractionList, exception *Exception, err error)
func (*ProxySession) GetParticipant ¶
func (session *ProxySession) GetParticipant(participantID string) (response Participant, exception *Exception, err error)
func (*ProxySession) ListParticipants ¶
func (session *ProxySession) ListParticipants() (response []Participant, exception *Exception, err error)
type ProxySessionRequest ¶
type SmsResponse ¶
type SmsResponse struct { Sid string `json:"sid"` DateCreated string `json:"date_created"` DateUpdate string `json:"date_updated"` DateSent string `json:"date_sent"` AccountSid string `json:"account_sid"` To string `json:"to"` From string `json:"from"` MediaUrl string `json:"media_url"` Body string `json:"body"` Status string `json:"status"` Direction string `json:"direction"` ApiVersion string `json:"api_version"` Price *string `json:"price,omitempty"` Url string `json:"uri"` }
SmsResponse is returned after a text/sms message is posted to Twilio
func (*SmsResponse) DateCreatedAsTime ¶
func (sms *SmsResponse) DateCreatedAsTime() (time.Time, error)
Returns SmsResponse.DateCreated as a time.Time object instead of a string.
func (*SmsResponse) DateSentAsTime ¶
func (sms *SmsResponse) DateSentAsTime() (time.Time, error)
Returns SmsResponse.DateSent as a time.Time object instead of a string.
func (*SmsResponse) DateUpdateAsTime ¶
func (sms *SmsResponse) DateUpdateAsTime() (time.Time, error)
Returns SmsResponse.DateUpdate as a time.Time object instead of a string.
type Twilio ¶
type Twilio struct { AccountSid string AuthToken string BaseUrl string VideoUrl string PricingUrl string MessagingUrl string NotifyUrl string HTTPClient *http.Client APIKeySid string APIKeySecret string }
Twilio stores basic information important for connecting to the twilio.com REST api such as AccountSid and AuthToken.
func NewTwilioClient ¶
Create a new Twilio struct.
func NewTwilioClientCustomHTTP ¶
Create a new Twilio client, optionally using a custom http.Client
func (*Twilio) AddPhoneNumber ¶
func (twilio *Twilio) AddPhoneNumber()
func (*Twilio) CallWithApplicationCallbacks ¶
func (twilio *Twilio) CallWithApplicationCallbacks(from, to, applicationSid string) (*VoiceResponse, *Exception, error)
Place a voice call with an ApplicationSid specified.
func (*Twilio) CallWithUrlCallbacks ¶
func (twilio *Twilio) CallWithUrlCallbacks(from, to string, callbackParameters *CallbackParameters) (*VoiceResponse, *Exception, error)
Place a voice call with a list of callbacks specified.
func (*Twilio) CheckRequestSignature ¶
CheckRequestSignature checks that the X-Twilio-Signature header on a request matches the expected signature defined by the GenerateSignature function.
The baseUrl parameter will be prepended to the request URL. It is useful for specifying the protocol and host parts of the server URL hosting your endpoint.
Passing a non-POST request or a request without the X-Twilio-Signature header is an error.
func (*Twilio) CreateCopilotService ¶
func (twilio *Twilio) CreateCopilotService(options *CreateCopilotServiceOptions) (copilotResponse *CopilotService, exception *Exception, err error)
func (*Twilio) CreateNotifyService ¶
func (twilio *Twilio) CreateNotifyService(options *CreateNotifyServiceOptions) (notifyService *NotifyService, exception *Exception, err error)
func (*Twilio) CreateVideoRoom ¶
func (twilio *Twilio) CreateVideoRoom(options *createRoomOptions) (videoResponse *VideoResponse, exception *Exception, err error)
CreateVideoRoom creates a video communication session for participants to connect to. See https://www.twilio.com/docs/video/api/rooms-resource for more information.
func (*Twilio) DeleteCopilotService ¶
func (*Twilio) DeleteNotifyService ¶
func (*Twilio) DeleteProxyService ¶
func (*Twilio) DeleteProxySession ¶
func (*Twilio) DeleteResource ¶
func (*Twilio) EndVideoRoom ¶
func (twilio *Twilio) EndVideoRoom(nameOrSid string) (videoResponse *VideoResponse, exception *Exception, err error)
EndVideoRoom stops a single video session by name or by Sid, and disconnects all participants. See https://www.twilio.com/docs/video/api/rooms-resource for more information.
func (*Twilio) GenerateSignature ¶
GenerateSignature computes the Twilio signature for verifying the authenticity of a request. It is based on the specification at: https://www.twilio.com/docs/security#validating-requests
func (*Twilio) GetCall ¶
func (twilio *Twilio) GetCall(sid string) (*VoiceResponse, *Exception, error)
GetCall uses Twilio to get information about a voice call. See https://www.twilio.com/docs/voice/api/call
func (*Twilio) GetCopilotService ¶
func (twilio *Twilio) GetCopilotService(sid string) (copilotResponse *CopilotService, exception *Exception, err error)
func (*Twilio) GetCopilotServices ¶
func (twilio *Twilio) GetCopilotServices() (copilotServiceList *CopilotServiceList, exception *Exception, err error)
func (*Twilio) GetCountriesPricing ¶
func (twilio *Twilio) GetCountriesPricing() (pricingList *PricingList, exception *Exception, err error)
func (*Twilio) GetFaxes ¶
func (t *Twilio) GetFaxes(to, from, createdOnOrBefore, createdAfter string) ([]*FaxResource, *Exception, error)
GetFaxes gets faxes for a Twilio account. See https://www.twilio.com/docs/fax/api/faxes#fax-list-resource
func (*Twilio) GetPhoneNumbers ¶
func (twilio *Twilio) GetPhoneNumbers() (incomingPhoneNumbers *IncomingPhoneNumbers, exception *Exception, err error)
func (*Twilio) GetPricing ¶
func (twilio *Twilio) GetPricing(countryISO string) (pricingResponse *PricingResponse, exception *Exception, err error)
func (*Twilio) GetProxyService ¶
func (twilio *Twilio) GetProxyService(sid string) (response *ProxyService, exception *Exception, err error)
func (*Twilio) GetProxySession ¶
func (twilio *Twilio) GetProxySession(serviceID, sessionID string) (response *ProxySession, exception *Exception, err error)
func (*Twilio) GetSMS ¶
func (twilio *Twilio) GetSMS(sid string) (smsResponse *SmsResponse, exception *Exception, err error)
GetSMS uses Twilio to get information about a text message. See https://www.twilio.com/docs/api/rest/sms for more information.
func (*Twilio) GetServicesWithAlphaSenders ¶
func (twilio *Twilio) GetServicesWithAlphaSenders() (copilotServiceList *CopilotServiceList, exception *Exception, err error)
func (*Twilio) GetVideoRoom ¶
func (twilio *Twilio) GetVideoRoom(nameOrSid string) (videoResponse *VideoResponse, exception *Exception, err error)
GetVideoRoom retrievs a single video session by name or by Sid. See https://www.twilio.com/docs/video/api/rooms-resource for more information.
func (*Twilio) ListVideoRooms ¶
func (twilio *Twilio) ListVideoRooms(options *ListVideoRoomOptions) (videoResponse *ListVideoReponse, exception *Exception, err error)
ListVideoRooms returns a list of all video rooms. See https://www.twilio.com/docs/video/api/rooms-resource for more information.
func (*Twilio) NewAccessToken ¶
func (twilio *Twilio) NewAccessToken() *AccessToken
NewAccessToken creates a new Access Token which can be used to authenticate Twilio Client SDKs for a short period of time.
func (*Twilio) NewProxyService ¶
func (twilio *Twilio) NewProxyService(service ProxyServiceRequest) (response *ProxyService, exception *Exception, err error)
Create a new Twilio Service
func (*Twilio) NewProxySession ¶
func (twilio *Twilio) NewProxySession(serviceID string, req ProxySessionRequest) (response *ProxySession, exception *Exception, err error)
Create a new Twilio Service
func (*Twilio) SendFax ¶
func (t *Twilio) SendFax(to, from, mediaUrl, quality, statusCallback string, storeMedia bool) (*FaxResource, *Exception, error)
SendFax uses Twilio to send a fax. See https://www.twilio.com/docs/fax/api/faxes#list-post for more information.
func (*Twilio) SendMMS ¶
func (twilio *Twilio) SendMMS(from, to, body, mediaUrl, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
SendMultimediaMessage uses Twilio to send a multimedia message.
func (*Twilio) SendSMS ¶
func (twilio *Twilio) SendSMS(from, to, body, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
SendTextMessage uses Twilio to send a text message. See http://www.twilio.com/docs/api/rest/sending-sms for more information.
func (*Twilio) SendSMSWithCopilot ¶
func (twilio *Twilio) SendSMSWithCopilot(params *CopilotParams) (smsResponse *SmsResponse, exception *Exception, err error)
SendSMSWithCopilot uses Twilio Copilot to send a text message. See https://www.twilio.com/docs/api/rest/sending-messages-copilot
func (*Twilio) UpdateNotifyService ¶
func (twilio *Twilio) UpdateNotifyService(serviceSID string, options *CreateNotifyServiceOptions) (notifyService *NotifyService, exception *Exception, err error)
func (*Twilio) UpdateProxyService ¶
func (twilio *Twilio) UpdateProxyService(sid string, service ProxyServiceRequest) (response *ProxyService, exception *Exception, err error)
func (*Twilio) UpdateProxySession ¶
func (twilio *Twilio) UpdateProxySession(serviceID, sessionID string, req ProxySessionRequest) (response *ProxySession, exception *Exception, err error)
type VideoCodecs ¶
type VideoCodecs string
VideoCodecs are the supported codecs when publishing a track to the room.
const ( VP8 VideoCodecs = "VP8" H264 VideoCodecs = "H264" )
type VideoGrant ¶
type VideoGrant struct {
Room string `json:"room,omitempty"`
}
VideoGrant is the permission to use the Video API which can be given to an Access Token.
type VideoResponse ¶
type VideoResponse struct { AccountSid string `json:"account_sid"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` Duration time.Duration `json:"duration"` EnableTurn bool `json:"enable_turn"` EndTime time.Time `json:"end_time"` MaxParticipants int64 `json:"max_participants"` MediaRegion MediaRegion `json:"media_region"` RecordParticipantsOnConnect bool `json:"record_participants_on_connect"` Sid string `json:"sid"` Status VideoStatus `json:"status"` StatusCallback string `json:"status_callback"` StatusCallbackMethod string `json:"status_callback_method"` Type VideoRoomType `json:"type"` UniqueName string `json:"unique_name"` URL string `json:"url"` }
VideoResponse is returned for a single room
type VideoRoomType ¶
type VideoRoomType string
VideoRoomType is how the participants connect to each other, whether peer-to-peer of routed through a TURN server.
const ( PeerToPeer VideoRoomType = "peer-to-peer" Group VideoRoomType = "group" )
type VideoStatus ¶
type VideoStatus string
VideoStatus is the status of a video room
const ( InProgress VideoStatus = "in-progress" Failed VideoStatus = "failed" Completed VideoStatus = "completed" )
type VoiceResponse ¶
type VoiceResponse struct { Sid string `json:"sid"` DateCreated string `json:"date_created"` DateUpdated string `json:"date_updated"` ParentCallSid string `json:"parent_call_sid"` AccountSid string `json:"account_sid"` To string `json:"to"` ToFormatted string `json:"to_formatted"` From string `json:"from"` FromFormatted string `json:"from_formatted"` PhoneNumberSid string `json:"phone_number_sid"` Status string `json:"status"` StartTime string `json:"start_time"` EndTime string `json:"end_time"` Duration int `json:"duration,string"` Price *float32 `json:"price,omitempty"` Direction string `json:"direction"` AnsweredBy string `json:"answered_by"` ApiVersion string `json:"api_version"` Annotation string `json:"annotation"` ForwardedFrom string `json:"forwarded_from"` GroupSid string `json:"group_sid"` CallerName string `json:"caller_name"` Uri string `json:"uri"` }
VoiceResponse contains the details about successful voice calls.
func (*VoiceResponse) DateCreatedAsTime ¶
func (vr *VoiceResponse) DateCreatedAsTime() (time.Time, error)
Returns VoiceResponse.DateCreated as a time.Time object instead of a string.
func (*VoiceResponse) DateUpdatedAsTime ¶
func (vr *VoiceResponse) DateUpdatedAsTime() (time.Time, error)
Returns VoiceResponse.DateUpdated as a time.Time object instead of a string.
func (*VoiceResponse) EndTimeAsTime ¶
func (vr *VoiceResponse) EndTimeAsTime() (time.Time, error)
Returns VoiceResponse.EndTime as a time.Time object instead of a string.
func (*VoiceResponse) StartTimeAsTime ¶
func (vr *VoiceResponse) StartTimeAsTime() (time.Time, error)
Returns VoiceResponse.StartTime as a time.Time object instead of a string.