Documentation ¶
Overview ¶
Package twirest provides a interface to Twilio REST API allowing the user to query meta-data from their account and, to initiate calls and send SMS.
Index ¶
- Constants
- Variables
- type Account
- type AccountResponse
- type AccountSubUris
- type Accounts
- type AccountsResponse
- type AddOutgoingCallerId
- type Call
- type CallResponse
- type CallSubUris
- type Calls
- type CallsResponse
- type ChangeQueue
- type Conference
- type ConferenceResponse
- type ConferenceSubUris
- type Conferences
- type ConferencesResponse
- type CreateQueue
- type DeQueue
- type DeleteNotification
- type DeleteOutgoingCallerId
- type DeleteParticipant
- type DeleteQueue
- type DeleteRecording
- type ExceptionResponse
- type MakeCall
- type Message
- type MessageResponse
- type Messages
- type MessagesResponse
- type ModifyCall
- type Notification
- type NotificationResponse
- type Notifications
- type NotificationsResponse
- type OutgoingCallerId
- type OutgoingCallerIdResponse
- type OutgoingCallerIds
- type OutgoingCallerIdsResponse
- type Page
- type Participant
- type ParticipantResponse
- type Participants
- type ParticipantsResponse
- type Queue
- type QueueMember
- type QueueMemberResponse
- type QueueMembers
- type QueueMembersResponse
- type QueueResponse
- type Queues
- type QueuesResponse
- type Recording
- type RecordingResponse
- type Recordings
- type RecordingsResponse
- type ResponseStatus
- type SendMessage
- type TwilioClient
- type TwilioResponse
- type UpdateOutgoingCallerId
- type UpdateParticipant
- type UsageRecordResponse
- type UsageRecordSubUris
- type UsageRecords
- type UsageRecordsResponse
- type ValidationRequestResponse
Constants ¶
const ( TwiInit = "init" TwiQueued = "queued" TwiSending = "sending" TwiSent = "sent" TwiReceiving = "receiving" TwiReceived = "received" TwiFailed = "failed" TwiRinging = "ringing" TwiInProgress = "in-progress" TwiCanceled = "canceled" TwiCompleted = "completed" TwiBusy = "busy" TwiNoAnswer = "no-answer" )
Call, Message & Conference status strings
const ( TwiCalls = "calls" TwiCallsInbound = "calls-inbound" TwiCallsInboundLocal = "calls-inbound-local" TwiCallsInboundTollfree = "calls-inbound-tollfree" TwiCallsOutbound = "calls-outbound" TwiCallsClient = "calls-client" TwiCallsSip = "calls-sip" TwiSms = "sms" TwiSmsInbound = "sms-inbound" TwiSmsInboundShortcode = "sms-inbound-shortcode" TwiSmsInboundLongcode = "sms-inbound-longcode" TwiPhoneNumbers = "phonenumbers" TwiPhoneNumbersTollFree = "phonenumbers-tollfree" TwiPhoneNumbersLocal = "phonenumbers-local" TwiShortcodes = "shortcodes" TwiShortcodesVanity = "shortcodes-vanity" TwiShortcodesRandom = "shortcodes-random" TwiShortcodesCustomerOwned = "shortcodes-customerowned" TwiCallerIdLookups = "calleridlookups" TwiRecordings = "recordings" TwiTranscriptions = "transcriptions" TwiRecordingStorage = "recordingstorage" TwiTotalPrice = "totalprice" )
UsageRecords categories
const ( TwiDaily = "Daily" TwiMonthly = "Monthly" TwiYearly = "Yearly" TwiAllTime = "AllTime" TwiToday = "Today" TwiYesterday = "Yesterday" TwiThisMonth = "ThisMonth" TwiLastMonth = "LastMonth" )
UsageRecords subresources
const ( TwiClosed = "closed" TwiSuspended = "suspended" TwiActive = "active" )
Account status strings
const ApiVer string = "2010-04-01"
Variables ¶
var ErrSignature = errors.New("Invalid X-Twilio-Signature")
ErrSignature is used to signify that ValidateRequest was not able to confirm the received signature as being correct.
Functions ¶
This section is empty.
Types ¶
type AccountResponse ¶
type AccountSubUris ¶
type AccountsResponse ¶
type AccountsResponse struct { Page Account []AccountResponse }
type AddOutgoingCallerId ¶
type Call ¶
type Call struct { Sid string // CallSid Recordings bool Notifications bool // contains filtered or unexported fields }
Request call information about a single call
type CallResponse ¶
type CallResponse struct { Sid string ParentCallSid string DateCreated string DateUpdated string AccountSid string To string From string PhoneNumberSid string Status string StartTime string EndTime string Duration string Price string PriceUnit string Direction string AnsweredBy string ForwardedFrom string CallerName string Uri string SubResourceUris *CallSubUris }
type CallSubUris ¶
type Calls ¶
type Calls struct { To string `To=` From string `From=` Status string `Status=` StartTime string `StartTime=` StartTimeBefore string `StartTime<=` StartTimeAfter string `StartTime>=` ParentCallSid string `ParentCallSid=` // contains filtered or unexported fields }
Request list of calls made to and from account
type CallsResponse ¶
type CallsResponse struct { Page Call []CallResponse }
type ChangeQueue ¶
type ChangeQueue struct { Sid string FriendlyName string `FriendlyName=` MaxSize string `MaxSize=` // contains filtered or unexported fields }
Request to change queue properties
type Conference ¶
type Conference struct { Sid string // contains filtered or unexported fields }
Resource for individual conference instance
type ConferenceResponse ¶
type ConferenceSubUris ¶
type ConferenceSubUris struct {
Participants string
}
type Conferences ¶
type Conferences struct { Status string `Status=` FriendlyName string `FriendlyName=` DateCreated string `DateCreated=` DateCreatedBefore string `DateCreated<=` DateCreatedAfter string `DateCreated>=` DateUpdated string `DateUpdated=` DateUpdatedBefore string `DateUpdated<=` DateUpdatedAfter string `DateUpdated>=` // contains filtered or unexported fields }
List conferences within an account
type ConferencesResponse ¶
type ConferencesResponse struct { Page Conference []ConferenceResponse }
type CreateQueue ¶
type CreateQueue struct { FriendlyName string `FriendlyName=` MaxSize string `MaxSize=` // contains filtered or unexported fields }
Create a new queue
type DeQueue ¶
type DeQueue struct { Sid string // Queue Sid CallSid string // either this field or Front is required Front bool Url string `Url=` Method string `Method=` // contains filtered or unexported fields }
Remove a member from a queue and redirect the member's call to a TwiML site
type DeleteNotification ¶
type DeleteNotification struct { Sid string // contains filtered or unexported fields }
DeleteNotification struct for removal of a notification
type DeleteOutgoingCallerId ¶
type DeleteOutgoingCallerId struct { Sid string // contains filtered or unexported fields }
type DeleteParticipant ¶
type DeleteParticipant struct { Sid string // Conference Sid CallSid string // required field // contains filtered or unexported fields }
Remove a participant from a conference
type DeleteQueue ¶
type DeleteQueue struct { Sid string // QueueSid // contains filtered or unexported fields }
Remove a queue
type DeleteRecording ¶
type DeleteRecording struct { Sid string // RecordingSid // contains filtered or unexported fields }
Delete a recording
type ExceptionResponse ¶
type MakeCall ¶
type MakeCall struct { From string `From=` To string `To=` Url string `Url=` ApplicationSid string `ApplicationSid=` Method string `Method=` FallbackUrl string `FallbackUrl=` FallbackMethod string `FallbackMethod=` StatusCallback string `StatusCallback=` StatusCallbackMethod string `StatusCallbackMethod=` SendDigits string `SendDigits=` IfMachine string `IfMachine=` Timeout string `Timeout=` Record string `Record=` SipAuthUsername string `SipAuthUsername=` SipAuthPassword string `SipAuthPassword=` // contains filtered or unexported fields }
Request to make a phone call
type Message ¶
type Message struct { Sid string // MessageSid Media bool MediaSid string // contains filtered or unexported fields }
Message struct for request of single message
type MessageResponse ¶
type Messages ¶
type Messages struct { To string `To=` From string `From=` DateSent string `DateSent=` DateSentBefore string `DateSent<=` DateSentAfter string `DateSent>=` // contains filtered or unexported fields }
Messages struct for request of list of messages
type MessagesResponse ¶
type MessagesResponse struct { Page Message []MessageResponse }
type ModifyCall ¶
type ModifyCall struct { Sid string Url string `Url=` Method string `Method=` Status string `Status=` FallbackUrl string `FallbackUrl=` FallbackMethod string `FallbackMethod=` StatusCallback string `StatusCallback=` StatusCallbackMethod string `StatusCallbackMethod=` // contains filtered or unexported fields }
Request to modify call in queue/progress
type Notification ¶
type Notification struct { Sid string // contains filtered or unexported fields }
Notification struct for request of a specific notification
type NotificationResponse ¶
type NotificationResponse struct { Sid string DateCreated string DateUpdated string AccountSid string CallSid string ApiVersion string Log string ErrorCode string MoreInfo string MessageText string MessageDate string RequestUrl string RequestMethod string Uri string // The fields below are only included in // resource from 'Notification' request RequestVariables string ResponseHeaders string ResponseBody string }
type Notifications ¶
type Notifications struct { Log string `Log=` MsgDate string `MessageDate=` MsgDateBefore string `MessageDate<=` MsgDateAfter string `MessageDate>=` // contains filtered or unexported fields }
Notifications struct for request of a possible list of notifications
type NotificationsResponse ¶
type NotificationsResponse struct { Page Notification []NotificationResponse }
type OutgoingCallerId ¶
type OutgoingCallerId struct { Sid string // contains filtered or unexported fields }
Get outgoing caller ID
type OutgoingCallerIds ¶
type OutgoingCallerIds struct { PhoneNumber string `PhoneNumber=` FriendlyName string `FriendlyName=` // contains filtered or unexported fields }
Get outgoing caller IDs
type OutgoingCallerIdsResponse ¶
type OutgoingCallerIdsResponse struct { Page OutgoingCallerId []OutgoingCallerIdResponse }
type Page ¶
type Page struct { Page uint `xml:"page,attr"` NumPages uint `xml:"numpages,attr"` PageSize uint `xml:"pagesize,attr"` Total uint `xml:"total,attr"` Start uint `xml:"start,attr"` End uint `xml:"end,attr"` Uri string `xml:"uri,attr"` FirstPageUri string `xml:"firstpageuri,attr"` PreviousPageUri string `xml:"previouspageuri,attr"` NextPageUri string `xml:"nextpageuri,attr"` LastPageUri string `xml:"lastpageuri,attr"` }
type Participant ¶
type Participant struct { Sid string // Conference Sid CallSid string // required field // contains filtered or unexported fields }
Resource about single conference participant
type ParticipantResponse ¶
type Participants ¶
type Participants struct { Sid string // Conference Sid Muted string `Muted=` // contains filtered or unexported fields }
Request list of participants in a conference
type ParticipantsResponse ¶
type ParticipantsResponse struct { Page Participant []ParticipantResponse }
type Queue ¶
type Queue struct { Sid string // QueueSid // contains filtered or unexported fields }
Get resource for an individual Queue instance
type QueueMember ¶
type QueueMember struct { Sid string // QueueSid CallSid string // either this field or Front is required Front bool // contains filtered or unexported fields }
Request resource for a queue member
type QueueMemberResponse ¶
type QueueMembers ¶
type QueueMembers struct { Sid string // QueueSid // contains filtered or unexported fields }
List members of a queue
type QueueMembersResponse ¶
type QueueMembersResponse struct { Page QueueMember []QueueMemberResponse }
type QueueResponse ¶
type Queues ¶
type Queues struct {
// contains filtered or unexported fields
}
List queues within an account
type QueuesResponse ¶
type QueuesResponse struct { Page Queue []QueueResponse }
type Recording ¶
type Recording struct { Sid string // RecordingSid // contains filtered or unexported fields }
Request resource for an individual recording
type RecordingResponse ¶
type Recordings ¶
type Recordings struct { CallSid string `CallSid=` DateCreated string `DateCreated=` DateCreatedBefore string `DateCreated<=` DateCreatedAfter string `DateCreated>=` // contains filtered or unexported fields }
List recordings resource
type RecordingsResponse ¶
type RecordingsResponse struct { Page Recording []RecordingResponse }
type ResponseStatus ¶
type SendMessage ¶
type SendMessage struct { Text string `Body=` MediaUrl string `MediaUrl=` From string `From=` To string `To=` MessagingServiceSid string `MessagingServiceSid=` ApplicationSid string `ApplicationSid=` StatusCallback string `StatusCallback=` // contains filtered or unexported fields }
Message struct for request to send a message
type TwilioClient ¶
type TwilioClient struct {
// contains filtered or unexported fields
}
TwilioClient struct for holding a http client and user credentials
func (*TwilioClient) Request ¶
func (twiClient *TwilioClient) Request(reqStruct interface{}) ( TwilioResponse, error)
Request makes a REST resource or action request from twilio servers and returns the response. The type of request is determined by the request struct supplied.
func (*TwilioClient) ValidateRequest ¶
func (twiClient *TwilioClient) ValidateRequest(fullUrl string, req *http.Request) error
ValidateRequest will take the incoming http.Request on a Twilio callback URL and verify that the X-Twilio-Signature is correct. fullUrl must be in the format of https://www.exampe.com/twilio/callback?param1=exists
This can be used to create custom middleware to make it easy to verify the request is sent from Twilio. Documentation about this method is available at https://www.twilio.com/docs/api/security#validating-requests
type TwilioResponse ¶
type TwilioResponse struct { Accounts *AccountsResponse `xml:"Accounts"` Account *AccountResponse `xml:"Account"` Calls *CallsResponse `xml:"Calls"` Call *CallResponse `xml:"Call"` Conferences *ConferencesResponse `xml:"Conferences"` Conference *ConferenceResponse `xml:"Conference"` Exception *ExceptionResponse `xml:"RestException"` Messages *MessagesResponse `xml:"Messages"` Message *MessageResponse `xml:"Message"` Notifications *NotificationsResponse `xml:"Notifications"` Notification *NotificationResponse `xml:"Notification"` OutgoingCallerIds *OutgoingCallerIdsResponse `xml:"OutgoingCallerIds"` OutgoingCallerId *OutgoingCallerIdResponse `xml:"OutgoingCallerId"` Participants *ParticipantsResponse `xml:"Participants"` Participant *ParticipantResponse `xml:"Participant"` Recordings *RecordingsResponse `xml:"Recordings"` Recording *RecordingResponse `xml:"Recording"` Queues *QueuesResponse `xml:"Queues"` Queue *QueueResponse `xml:"Queue"` QueueMembers *QueueMembersResponse `xml:"QueueMembers"` QueueMember *QueueMemberResponse `xml:"QueueMember"` UsageRecords *UsageRecordsResponse `xml:"UsageRecords"` ValidationRequest *ValidationRequestResponse `xml:"ValidationRequest"` Status ResponseStatus }
TwilioResponse holds one possible resource/response depending on type of request plus a Status struct.
type UpdateOutgoingCallerId ¶
type UpdateParticipant ¶
type UpdateParticipant struct { Sid string // Conference Sid CallSid string // required field Muted string `Muted=` // contains filtered or unexported fields }
Request to change the status of a participant
type UsageRecordResponse ¶
type UsageRecordSubUris ¶
type UsageRecords ¶
type UsageRecords struct { SubResource string Category string `Category=` StartDate string `StartDate=` EndDate string `EndDate=` // contains filtered or unexported fields }
Request usage by the account
type UsageRecordsResponse ¶
type UsageRecordsResponse struct { Page UsageRecord []UsageRecordResponse }