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 AvailablePhoneNumber
- type CallbackParameters
- type Capabilities
- type Exception
- type ExceptionCode
- type FaxBase
- type FaxMediaResource
- type FaxResource
- type FaxResourcesList
- type Grant
- type IdentityParams
- type Interaction
- type InteractionData
- type InteractionList
- type ListResources
- type ListResponse
- type ListVideoReponse
- type ListVideoRoomOptions
- type Lookup
- type LookupReq
- type MediaRegion
- type Meta
- type Participant
- type ParticipantList
- type ParticipantRequest
- type PhoneNumbersResponse
- 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 QueueResponse
- type SMSWebhook
- type SmsResponse
- type SubresourceURIs
- type Twilio
- func (twilio *Twilio) CallUpdate(callSid string, formValues url.Values) (*VoiceResponse, *Exception, error)
- 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) CreateAddress() error
- func (twilio *Twilio) CreateDocument() error
- func (twilio *Twilio) CreateIdentity() error
- func (twilio *Twilio) CreateQueue(friendlyName string) (*QueueResponse, *Exception, error)
- func (twilio *Twilio) CreateVideoRoom(options *createRoomOptions) (videoResponse *VideoResponse, exception *Exception, err error)
- func (t *Twilio) DeleteFax(faxSid string) (*Exception, 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) 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 (t *Twilio) GetFax(faxSid string) (*FaxResource, *Exception, error)
- func (t *Twilio) GetFaxes(to, from, createdOnOrBefore, createdAfter string) ([]*FaxResource, *Exception, error)
- func (twilio *Twilio) GetPhoneNumbers(countryCode string) ([]AvailablePhoneNumber, 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) GetUsage(category, startDate, endDate string, includeSubaccounts bool) (*UsageResponse, *Exception, 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) LookupNoCarrier(phoneNumber string) (Lookup, 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(messagingServiceSid, to, body, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
- func (twilio *Twilio) SendWhatsApp(from, to, body, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
- func (twilio *Twilio) SubmitLookup(req LookupReq) (Lookup, 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 UsageParameters
- type UsageRecord
- type UsageResponse
- type VideoCodecs
- type VideoGrant
- type VideoResponse
- type VideoRoomType
- type VideoStatus
- type VoiceGrant
- type VoiceGrantIncoming
- type VoiceGrantOutgoing
- 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 AvailablePhoneNumber ¶ added in v0.1.5
type AvailablePhoneNumber struct { FriendlyName string `json:"friendly_name"` PhoneNumber string `json:"phone_number"` // Lata string `json:"lata"` // RateCenter string `json:"rate_center"` Latitude string `json:"latitude"` Longitude string `json:"longitude"` Locality string `json:"locality"` Region string `json:"region"` PostalCode *string `json:"postal_code"` IsoCountry string `json:"iso_country"` AddressRequirements string `json:"address_requirements"` Beta bool `json:"beta"` Capabilities Capabilities `json:"capabilities"` }
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 MachineDetectionSpeechThreshold int // Optional MachineDetectionSpeechEndThreshold int // Optional MachineDetectionSilenceTimeout 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
NewCallbackParameters returns a CallbackParameters type with the specified url and CallbackParameters.Timeout set to 60.
type Capabilities ¶ added in v0.1.6
type Exception ¶
type Exception struct { Status int `json:"status"` // HTTP specific error code Message string `json:"message"` // HTTP error message Code ExceptionCode `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 ¶
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 {
GrantName() string
}
Grant is a perimssion given to the Access Token. Types include Chat, Video etc.
type IdentityParams ¶ added in v0.1.9
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 ListResponse ¶ added in v0.1.5
type ListResponse struct {
AvailablePhoneNumbers []AvailablePhoneNumber `json:"available_phone_numbers"`
}
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 Lookup ¶
type Lookup struct { Carrier *struct { ErrorCode *int `json:"error_code"` MobileCountryCode string `json:"mobile_country_code"` MobileNetworkCode string `json:"mobile_network_code"` Name string `json:"name"` Type string `json:"type"` } `json:"carrier"` CountryCode string `json:"country_code"` NationalFormat string `json:"national_format"` PhoneNumber string `json:"phone_number"` URL string `json:"url"` }
Lookup Go-representation of Twilio REST API's lookup. https://www.twilio.com/docs/api/rest/lookups
type LookupReq ¶
LookupReq Go-representation of Twilio REST API's lookup request. https://www.twilio.com/docs/api/rest/lookups#lookups-query-parameters
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 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 PhoneNumbersResponse ¶
type PhoneNumbersResponse struct { CountryCode string `json:"country_code"` Country string `json:"country"` URI string `json:"uri"` Beta bool `json:"beta"` SubresourceURIs SubresourceURIs `json:"subresource_uris"` }
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)
AddParticipant adds 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 QueueResponse ¶
type SMSWebhook ¶
type SMSWebhook struct { AccountSid string `json:"AccountSid"` APIVersion string `json:"ApiVersion"` // SMS Specific Body string `json:"Body"` SmsSid string `json:"SmsSid"` MessageSid string `json:"MessageSid"` NumMedia string `json:"NumMedia"` NumSegments string `json:"NumSegments"` SmsStatus string `json:"SmsStatus"` SmsMessageSid string `json:"SmsMessageSid"` To string `json:"To"` ToCity string `json:"ToCity"` ToState string `json:"ToState"` ToZip string `json:"ToZip"` ToCountry string `json:"ToCountry"` From string `json:"From"` FromCity string `json:"FromCity"` FromState string `json:"FromState"` FromZip string `json:"FromZip"` FromCountry string `json:"FromCountry"` // The ContentTypes for the Media stored at MediaUrl{N}. // The order of MediaContentType{N} matches the order of MediaUrl{N} // Let's define 10 items to be safe MediaContentType0 string `json:"MediaContentType0"` MediaUrl0 string `json:"MediaUrl0"` MediaContentType1 string `json:"MediaContentType1"` MediaUrl1 string `json:"MediaUrl1"` MediaContentType2 string `json:"MediaContentType2"` MediaUrl2 string `json:"MediaUrl2"` MediaContentType3 string `json:"MediaContentType3"` MediaUrl3 string `json:"MediaUrl3"` MediaContentType4 string `json:"MediaContentType4"` MediaUrl4 string `json:"MediaUrl4"` MediaContentType5 string `json:"MediaContentType5"` MediaUrl5 string `json:"MediaUrl5"` MediaContentType6 string `json:"MediaContentType6"` MediaUrl6 string `json:"MediaUrl6"` MediaContentType7 string `json:"MediaContentType7"` MediaUrl7 string `json:"MediaUrl7"` MediaContentType8 string `json:"MediaContentType8"` MediaUrl8 string `json:"MediaUrl8"` MediaContentType9 string `json:"MediaContentType9"` MediaUrl9 string `json:"MediaUrl9"` MediaContentType10 string `json:"MediaContentType10"` MediaUrl10 string `json:"MediaUrl10"` }
https://www.twilio.com/docs/sms/twiml#request-parameters SMS webhooks received from inbound SMS messages. If your server (or a Twilio function) responds with valid TwiML, this will be processed. This means it is possible to send an automated text message response back.
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)
DateCreatedAsTime returns SmsResponse.DateCreated as a time.Time object instead of a string.
func (*SmsResponse) DateSentAsTime ¶
func (sms *SmsResponse) DateSentAsTime() (time.Time, error)
DateSentAsTime returns SmsResponse.DateSent as a time.Time object instead of a string.
func (*SmsResponse) DateUpdateAsTime ¶
func (sms *SmsResponse) DateUpdateAsTime() (time.Time, error)
DateUpdateAsTime returns SmsResponse.DateUpdate as a time.Time object instead of a string.
type SubresourceURIs ¶
type Twilio ¶
type Twilio struct { AccountSid string AuthToken string BaseUrl string VideoUrl string LookupURL 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) CallUpdate ¶
func (twilio *Twilio) CallUpdate(callSid string, formValues url.Values) (*VoiceResponse, *Exception, error)
Update an existing call
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) CreateAddress ¶ added in v0.1.7
func (*Twilio) CreateDocument ¶ added in v0.1.7
func (*Twilio) CreateIdentity ¶ added in v0.1.7
func (*Twilio) CreateQueue ¶
func (twilio *Twilio) CreateQueue(friendlyName string) (*QueueResponse, *Exception, 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) DeleteProxyService ¶
func (*Twilio) DeleteProxySession ¶
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) 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(countryCode string) ([]AvailablePhoneNumber, 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) 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) LookupNoCarrier ¶
LookupNoCarrier looks up a phone number's details without the carrier
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)
SendMMS 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)
SendSMS 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(messagingServiceSid, to, body, statusCallback, applicationSid string) (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) SendWhatsApp ¶
func (twilio *Twilio) SendWhatsApp(from, to, body, statusCallback, applicationSid string) (smsResponse *SmsResponse, exception *Exception, err error)
SendWhatsApp uses Twilio to send a WhatsApp message. See https://www.twilio.com/docs/sms/whatsapp/tutorial/send-and-receive-media-messages-whatsapp-python
func (*Twilio) SubmitLookup ¶
SubmitLookup sends a lookup request populating form fields only if they contain a non-zero value.
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 UsageParameters ¶
type UsageParameters struct { Category string // Optional StartDate string // Optional, in YYYY-MM-DD or as offset EndDate string // Optional, in YYYY-MM-DD or as offset IncludeSubaccounts bool // Optional }
These are the parameters to use when you are requesting account usage. See https://www.twilio.com/docs/usage/api/usage-record#read-multiple-usagerecord-resources for more info.
type UsageRecord ¶
type UsageRecord struct { AccountSid string `json:"account_sid"` Category string `json:"category"` Description string `json:"description"` StartDate string `json:"start_date"` EndDate string `json:"end_date"` Price string `json:"price"` PriceUnit string `json:"price_unit"` Count int `json:"count,string"` CountUnit string `json:"count_unit"` Usage int `json:"usage,string"` UsageUnit string `json:"usage_unit"` }
UsageRecord specifies the usage for a particular usage category. See https://www.twilio.com/docs/usage/api/usage-record#usagerecord-properties for more info.
type UsageResponse ¶
type UsageResponse struct { PageSize int `json:"page_size"` Page int `json:"page"` UsageRecords []UsageRecord `json:"usage_records"` }
UsageResponse contains information about account usage.
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.
func (*VideoGrant) GrantName ¶
func (g *VideoGrant) GrantName() string
GrantName is the key to identify this as a Video grant.
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 VoiceGrant ¶
type VoiceGrant struct { Incoming VoiceGrantIncoming `json:"incoming,omitempty"` Outgoing VoiceGrantOutgoing `json:"outgoing,omitempty"` EndpointID string `json:"endpoint_id,omitempty"` PushCredentialSID string `json:"push_credential_sid,omitempty"` }
VoiceGrant is the permission to use the Voice API and act as a Twilio Client.
func (VoiceGrant) GrantName ¶
func (g VoiceGrant) GrantName() string
GrantName is the key to identify this as a Voice grant.
type VoiceGrantIncoming ¶
type VoiceGrantIncoming struct {
Allow bool `json:"allow"`
}
VoiceGrantIncoming represents the incoming options for a voice grant.
type VoiceGrantOutgoing ¶
type VoiceGrantOutgoing struct { ApplicationSID string `json:"application_sid,omitempty"` Params map[string]interface{} `json:"params,omitempty"` }
VoiceGrantOutgoing represents the outgoing options for a voice grant.
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"` PriceUnit string `json:"price_unit"` Price *string `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)
DateCreatedAsTime returns VoiceResponse.DateCreated as a time.Time object instead of a string.
func (*VoiceResponse) DateUpdatedAsTime ¶
func (vr *VoiceResponse) DateUpdatedAsTime() (time.Time, error)
DateUpdatedAsTime returns VoiceResponse.DateUpdated as a time.Time object instead of a string.
func (*VoiceResponse) EndTimeAsTime ¶
func (vr *VoiceResponse) EndTimeAsTime() (time.Time, error)
EndTimeAsTime returns VoiceResponse.EndTime as a time.Time object instead of a string.
func (*VoiceResponse) StartTimeAsTime ¶
func (vr *VoiceResponse) StartTimeAsTime() (time.Time, error)
StartTimeAsTime returns VoiceResponse.StartTime as a time.Time object instead of a string.