twilio

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetSender

func SetSender(phone string)

SetSender will set the default phone number used by the client's Send function.

Types

type Client

type Client struct {
	SenderNumber string
	// contains filtered or unexported fields
}

Client is a twilio client

func ClientFromClient

func ClientFromClient(sid, token string, c *http.Client) *Client

ClientFromClient will create a twilio client that uses a user given http.Client.

func NewClient

func NewClient(sid, token string) *Client

NewClient will create a new twilio client.

func (*Client) Send

func (c *Client) Send(to, body string) (*MessageResponse, error)

Send will a message given the recipient's phone number.

func (*Client) SendFrom

func (c *Client) SendFrom(from, to, body string) (*MessageResponse, error)

SendFrom will send a message given the sender's number and the recipient's number.

func (*Client) SetSender

func (c *Client) SetSender(phone string)

SetSender will set the default phone number used by the client's Send function.

type Error

type Error struct {
	Code     int    `json:"code"`
	Message  string `json:"message"`
	MoreInfo string `json:"more_info"`
	Status   int    `json:"status"`
}

Error is a twilio response error

func (*Error) Error

func (e *Error) Error() string

type MessageResponse

type MessageResponse struct {
	Sid                 string      `json:"sid"`
	DateCreated         string      `json:"date_created"`
	DateUpdated         string      `json:"date_updated"`
	DateSent            interface{} `json:"date_sent"`
	AccountSid          string      `json:"account_sid"`
	To                  string      `json:"to"`
	From                string      `json:"from"`
	MessagingServiceSid interface{} `json:"messaging_service_sid"`
	Body                string      `json:"body"`
	Status              string      `json:"status"`
	NumSegments         string      `json:"num_segments"`
	NumMedia            string      `json:"num_media"`
	Direction           string      `json:"direction"`
	APIVersion          string      `json:"api_version"`
	Price               interface{} `json:"price"`
	PriceUnit           string      `json:"price_unit"`
	ErrorCode           interface{} `json:"error_code"`
	ErrorMessage        interface{} `json:"error_message"`
	URI                 string      `json:"uri"`
	SubresourceUris     struct {
		Media string `json:"media"`
	} `json:"subresource_uris"`
}

MessageResponse is the json response given from sending a message.

func Send

func Send(to, body string) (*MessageResponse, error)

Send will a message given the recipient's phone number.

func SendFrom

func SendFrom(from, to, body string) (*MessageResponse, error)

SendFrom will send a message given the sender's number and the recipient's number.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL