Documentation
¶
Overview ¶
Package twilio provides support for interacting with Twilio REST API
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- type Exception
- type Message
- type MessageListParams
- type MessageParams
- type MessageService
- func (s *MessageService) Create(v url.Values) (*Message, *Response, error)
- func (s *MessageService) Get(sid string) (*Message, *Response, error)
- func (s *MessageService) List(params MessageListParams) ([]Message, *Response, error)
- func (s *MessageService) Send(from, to string, params MessageParams) (*Message, *Response, error)
- func (s *MessageService) SendSMS(from, to, body string) (*Message, *Response, error)
- type Pagination
- type Price
- type Response
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶ added in v0.1.0
Types ¶
type Client ¶ added in v0.1.0
type Client struct {
// User agent used when communicating with Twilio API
UserAgent string
// The Twilio API base URL
BaseURL *url.URL
// Credentials which is used for authentication during API request
AccountSid string
AuthSid string
AuthToken string
// Services used for communicating with different parts of the Twilio API
Messages *MessageService
// contains filtered or unexported fields
}
A client manages communication with Twilio API
func NewClient ¶ added in v0.1.0
NewClient returns a new Twilio API client. This will load default http.Client if httpClient is nil.
type Exception ¶
type Exception struct {
Status int `json:"status"`
Message string `json:"message"`
Code int `json:"code"`
MoreInfo string `json:"more_info"`
}
Exception holds information about error response returned by Twilio API
type Message ¶ added in v0.1.0
type Message struct {
AccountSid string `json:"account_sid"`
ApiVersion string `json:"api_version"`
Body string `json:"body"`
NumSegments int `json:"num_segments,string"`
NumMedia int `json:"num_media,string"`
DateCreated Timestamp `json:"date_created,omitempty"`
DateSent Timestamp `json:"date_sent,omitempty"`
DateUpdated Timestamp `json:"date_updated,omitempty"`
Direction string `json:"direction"`
From string `json:"from"`
Price Price `json:"price,omitempty"`
Sid string `json:"sid"`
Status string `json:"status"`
To string `json:"to"`
Uri string `json:"uri"`
}
type MessageListParams ¶ added in v0.1.0
type MessageParams ¶ added in v0.1.0
type MessageParams struct {
// The text of the message you want to send, limited to 1600 characters.
Body string
// The URL of the media you wish to send out with the message. Currently support: gif, png, and jpeg.
MediaUrl []string
StatusCallback string
ApplicationSid string
}
func (MessageParams) Validates ¶ added in v0.1.0
func (p MessageParams) Validates() error
type MessageService ¶ added in v0.1.0
type MessageService struct {
// contains filtered or unexported fields
}
func (*MessageService) Get ¶ added in v0.1.0
func (s *MessageService) Get(sid string) (*Message, *Response, error)
func (*MessageService) List ¶ added in v0.1.0
func (s *MessageService) List(params MessageListParams) ([]Message, *Response, error)
func (*MessageService) Send ¶ added in v0.1.0
func (s *MessageService) Send(from, to string, params MessageParams) (*Message, *Response, error)
Send Message with options. It's support required and optional parameters.
One of these parameters is required:
Body : The text of the message you want to send MediaUrl : The URL of the media you wish to send out with the message. Currently support: gif, png, and jpeg.
Optional parameters:
StatusCallback : A URL that Twilio will POST to when your message is processed. ApplicationSid : Twilio will POST `MessageSid` as well as other statuses to the URL in the `MessageStatusCallback` property of this application
type Pagination ¶
type Pagination struct {
Page int `json:"page"`
NumPages int `json:"num_pages"`
PageSize int `json:"page_size"`
Total int `json:"total"`
Start int `json:"start"`
End int `json:"end"`
Uri string `json:"uri"`
FirstPageUri string `json:"first_page_uri"`
PreviousPageUri string `json:"previous_page_uri"`
NextPageUri string `json:"next_page_uri"`
LastPageUri string `json:"last_page_uri"`
}
type Response ¶ added in v0.1.0
type Response struct {
*http.Response
Pagination
}
Wraps http.Response. So we can add more functionalities later.
func NewResponse ¶ added in v0.1.0
type Timestamp ¶
func (*Timestamp) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.