twiliogo

package module
v0.0.0-...-4deeae4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2018 License: MIT Imports: 11 Imported by: 0

README

Build Status

twilio-go

One of the many unofficial Go helper library for Twilio.

list of all libraries

Installation

go get github.com/fabriziomoscon/twiliogo

Documentation

GoDoc

Usage

Send a Text

package main

import (
  "fmt"
  twilio "github.com/fabriziomoscon/twiliogo"
)

func main() {
  client := twilio.NewClient("<ACCOUNT_SID>", "<AUTH_TOKEN>")

  message, err := twilio.NewMessage(client, "3334445555", "2223334444", twilio.Body("Hello World!"))

  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println(message.Status)
  }
}

Make a Call

package main

import (
  "fmt"
  twilio "github.com/fabriziomoscon/twiliogo"
)

func main() {
  client := twilio.NewClient("<ACCOUNT_SID>", "<AUTH_TOKEN>")

  call, err := twilio.NewCall(client, "8883332222", "3334443333", nil)

  if err != nil {
    fmt.Println(err)
  } else {
    fmt.Println("Call Queued!")
  }
}

Implemented Resources

  • Address
  • Application
  • Available Phone number
  • Incoming phone number
  • Calls
  • Messages
  • IncomingPhoneNumbers (partial)

Run Tests

Tests can be run using go test, as with most golang projects. This project also contains integration tests (where they can be done non-destructively using the API or the working Test Credential endpoints).

These integration tests can be run by providing the necessary environment variables to access the API, as in this Makefile:

test:
	@export API_KEY="<API KEY>";\
	export API_TOKEN="<API TOKEN>";\
	export TEST_KEY="<TEST KEY>";\
	export TEST_TOKEN="<TEST TOKEN>";\
	export TEST_FROM_NUMBER="<DEFAULT TEST CRED NUMBER>";\
	export FROM_NUMBER="<TEST FROM NUMBER>";\
	export TO_NUMBER="<TEST TO NUMBER>";\
	go test -v

To Do

Here are a few things that the project needs in order to reach v1.0:

  1. Complete test coverage. Right now, tests cover the bare minimum of usage for each feature implemented.
  2. Complete IncomingPhoneNumber functionality.
  3. Implement the following resources:
  • OutgoingCallerIds
  • ConnectApps
  • AuthorizedConnectApps
  • Conferences
  • Queues
  • Short Codes
  • Recordings
  • Transcriptions
  • Notifications
  • SIP Domains
  • IpAccessControlLists
  • CredentialLists
  • Usage Triggers

License

This project is licensed under the MIT License

Documentation

Index

Constants

View Source
const (
	IP_MESSAGING_ROOT     = "https://ip-messaging.twilio.com"
	IP_MESSAGING_VERSION  = "v1"
	IP_MESSAGING_ROOT_URL = IP_MESSAGING_ROOT + "/" + IP_MESSAGING_VERSION
)

Constants for the IP Messaging service.

View Source
const (
	PermissionCreateChannel         = "createChannel"
	PermissionJoinChannel           = "joinChannel"
	PermissionDestroyChannel        = "destroyChannel"
	PermissionInviteMember          = "inviteMember"
	PermissionRemoveMember          = "removeMember"
	PermissionEditChannelName       = "editChannelName"
	PermissionEditChannelAttributes = "editChannelAttributes"
	PermissionAddMember             = "addMember"
	PermissionEditAnyMessage        = "editAnyMessage"
	PermissionDeleteAnyMessage      = "deleteAnyMessage"
	PermissionSendMessage           = "sendMessage"
	PermissionLeaveChannel          = "leaveChannel"
	PermissionEditOwnMessage        = "editOwnMessage"
	PermissionDeleteOwnMessage      = "deleteOwnMessage"
)

Permissions allowed for IP Roles.

View Source
const (
	WebhookOnMessageSend    = "Webhooks.OnMessageSend"
	WebhookOnMessageRemove  = "Webhooks.OnMessageRemove"
	WebhookOnMessageUpdate  = "Webhooks.OnMessageUpdate"
	WebhookOnChannelAdd     = "Webhooks.OnChannelAdd"
	WebhookOnChannelUpdate  = "Webhooks.OnChannelUpdate"
	WebhookOnChannelDestroy = "Webhooks.OnChannelDestroy"
	WebhookOnMemberAdd      = "Webhooks.OnMemberAdd"
	WebhookOnMemberRemove   = "Webhooks.OnMemberRemove"
)

Webhooks available for services to specify

View Source
const ROOT = "https://api.twilio.com"
View Source
const VERSION = "2010-04-01"

Variables

This section is empty.

Functions

func DeleteIPChannel

func DeleteIPChannel(client *TwilioIPMessagingClient, serviceSid, sid string) error

DeleteIPChannel deletes the given IP Channel.

func DeleteIPCredential

func DeleteIPCredential(client *TwilioIPMessagingClient, sid string) error

DeleteIPCredential deletes the given IP Credential.

func DeleteIPRole

func DeleteIPRole(client *TwilioIPMessagingClient, serviceSid, sid string) error

DeleteIPRole deletes the given IP Role.

func DeleteIPService

func DeleteIPService(client *TwilioIPMessagingClient, sid string) error

DeleteIPService deletes the given IP Service.

func DeleteIPUser

func DeleteIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) error

DeleteIPUser deletes the given IP user.

func GetAvailablePhoneNumbers

func GetAvailablePhoneNumbers(client Client, isoCountryCode string, numType string, optionals ...Optional) (*[]AvaliablePhoneNumber, error)

func ReleasePhoneNumber

func ReleasePhoneNumber(client Client, sid string) error

func RemoveAddress

func RemoveAddress(client Client, accSid, addSid string) error

func RemoveIPMemberFromChannel

func RemoveIPMemberFromChannel(client *TwilioIPMessagingClient, serviceSid, channelSid, sid string) error

RemoveIPMemberFromChannel removes the given member from the channel.

Types

type Account

type Account struct {
	Sid             string   `json:"sid"`
	DateCreated     string   `json:"date_created"`
	DateUpdated     string   `json:"date_updated"`
	FriendlyName    string   `json:"friendly_name"`
	Type            string   `json:"type"`
	Status          string   `json:"status"`
	AuthToken       string   `json:"auth_token"`
	Uri             string   `json:"uri"`
	SubresourceUris []string `json:"subresources_uris"`
	OwnerAccountSid string   `json:"owner_account_sid"`
}

func GetAccount

func GetAccount(client Client, sid string) (*Account, error)

func NewAccount

func NewAccount(client Client, friendlyName string) (*Account, error)

type Address

type Address struct {
	Sid          string `json:"sid"`
	AccountSid   string `json:"account_sid"`
	FriendlyName string `json:"friendly_name"`
	CustomerName string `json:"vustomer_name"`
	Street       string `json:"street"`
	City         string `json:"city"`
	Region       string `json:"region"`
	PostalCode   string `json:"postal_code"`
	IsoCountry   string `json:"iso_country"`
	Uri          string `json:"uri"`
}

func GetAddress

func GetAddress(client Client, accSid string, addressId string) (*Address, error)

func NewAddress

func NewAddress(client Client, accSid string, optionals ...Optional) (*Address, error)

type Application

type Application struct {
	Sid                   string `json:"sid"`
	DateCreated           string `json:"date_created"`
	DateUpdated           string `json:"date_updated"`
	FriendlyName          string `json:"friendly_name"`
	AccountSid            string `json:"account_sid"`
	ApiVersion            string `json:"api_version"`
	VoiceUrl              string `json:"voice_url"`
	VoiceMethod           string `json:"voice_method"`
	VoiceFallbackUrl      string `json:"voice_fallback_url"`
	VoiceFallbackMethod   string `json:"voice_fallback_method"`
	StatusCallback        string `json:"status_callback"`
	StatusCallbackMethod  string `json:"status_callback_method"`
	VoiceCallerIdLookup   bool   `json:"voice_caller_id_lookup"`
	SmsUrl                string `json:"sms_url"`
	SmsMethod             string `json:"sms_method"`
	SmsFallbackUrl        string `json:"sms_fallback_url"`
	SmsFallbackMethod     string `json:"sms_fallback_method"`
	SmsStatusCallback     string `json:"sms_status_callback"`
	MessageStatusCallback string `json:"message_status_callback"`
	Uri                   string `json:"uri"`
}

func GetApplication

func GetApplication(client Client, accSid string, appId string) (*Application, error)

func NewApplication

func NewApplication(client Client, accSid string, optionals ...Optional) (*Application, error)

type ApplicationSid

type ApplicationSid string

func (ApplicationSid) GetParam

func (applicationSid ApplicationSid) GetParam() (string, string)

type AreaCode

type AreaCode string

func (AreaCode) GetParam

func (areaCode AreaCode) GetParam() (string, string)

type AvaliablePhoneNumber

type AvaliablePhoneNumber struct {
	FriendlyName        string       `json:"friendly_name"`
	PhoneNumber         string       `json:"phone_number"`
	IsoCountry          string       `json:"iso_country"`
	Capabilities        Capabilities `json:"capabilities"`
	AddressRequirements string       `json:"address_requirements"`
	Beta                bool         `json:"beta"`
	Lata                string       `json:"lata"`
	RateCenter          string       `json:"rate_center"`
	Latitude            string       `json:"latitude"`
	Longitude           string       `json:"longitude"`
	Region              string       `json:"region"`
	PostalCode          string       `json:"postal_code"`
}

type AvaliablePhoneNumberWrapper

type AvaliablePhoneNumberWrapper struct {
	URI  string          `json:"uri"`
	Data json.RawMessage `json:"available_phone_numbers"`
}

type Beta

type Beta bool

func (Beta) GetParam

func (beta Beta) GetParam() (string, string)

type Body

type Body string

func (Body) GetParam

func (body Body) GetParam() (string, string)

type Call

type Call struct {
	Sid            string `json:"sid"`
	ParentCallSid  string `json:"parent_call_sid"`
	DateCreated    string `json:"date_created"`
	DateUpdated    string `json:"date_updated"`
	AccountSid     string `json:"account_sid"`
	To             string `json:"to"`
	From           string `json:"from"`
	PhoneNumberSid string `json:"phone_number_sid"`
	Status         string `json:"status"`
	StartTime      string `json:"start_time"`
	EndTime        string `json:"end_time"`
	Duration       string `json:"duration"`
	Price          string `json:"price"`
	PriceUnit      string `json:"price_unit"`
	Direction      string `json:"direction"`
	AnsweredBy     string `json:"answered_by"`
	ForwardedFrom  string `json:"forwarded_from"`
	CallerName     string `json:"caller_name"`
	Uri            string `json:"uri"`
}

func GetCall

func GetCall(client Client, sid string) (*Call, error)

func NewCall

func NewCall(client Client, from, to string, callback Optional, optionals ...Optional) (*Call, error)

func (*Call) Update

func (call *Call) Update(client Client, optionals ...Optional) error

type CallList

type CallList struct {
	Client          Client
	Start           int    `json:"start"`
	Total           int    `json:"total"`
	NumPages        int    `json:"num_pages"`
	Page            int    `json:"page"`
	PageSize        int    `json:"page_size"`
	End             int    `json:"end"`
	Uri             string `json:"uri"`
	FirstPageUri    string `json:"first_page_uri"`
	LastPageUri     string `json:"last_page_uri"`
	NextPageUri     string `json:"next_page_uri"`
	PreviousPageUri string `json:"previous_page_uri"`
	Calls           []Call `json:"calls"`
}

func GetCallList

func GetCallList(client Client, optionals ...Optional) (*CallList, error)

func (*CallList) FirstPage

func (currentCallList *CallList) FirstPage() (*CallList, error)

func (*CallList) GetCalls

func (callList *CallList) GetCalls() []Call

func (*CallList) HasNextPage

func (currentCallList *CallList) HasNextPage() bool

func (*CallList) HasPreviousPage

func (currentCallList *CallList) HasPreviousPage() bool

func (*CallList) LastPage

func (currentCallList *CallList) LastPage() (*CallList, error)

func (*CallList) NextPage

func (currentCallList *CallList) NextPage() (*CallList, error)

func (*CallList) PreviousPage

func (currentCallList *CallList) PreviousPage() (*CallList, error)

type Callback

type Callback string

func (Callback) GetParam

func (callback Callback) GetParam() (string, string)

type Capabilities

type Capabilities struct {
	Voice bool `json:"voice"`
	SMS   bool `json:"SMS"`
	MMS   bool `json:"MMS"`
	FAX   bool `json:"fax"`
}

type City

type City string

func (City) GetParam

func (city City) GetParam() (string, string)

type Client

type Client interface {
	AccountSid() string
	AuthToken() string
	RootUrl() string
	// contains filtered or unexported methods
}

type Contains

type Contains string

For AvaliablePhoneNumbers

func (Contains) GetParam

func (contains Contains) GetParam() (string, string)

type CustomerName

type CustomerName string

for Address

func (CustomerName) GetParam

func (customerName CustomerName) GetParam() (string, string)

type DateSent

type DateSent string

func (DateSent) GetParam

func (dateSent DateSent) GetParam() (string, string)

type Distance

type Distance uint16

func (Distance) GetParam

func (distance Distance) GetParam() (string, string)

type Error

type Error struct {
	Description string
}

func (Error) Error

func (e Error) Error() string

type ExcludeAllAddressRequired

type ExcludeAllAddressRequired bool

func (ExcludeAllAddressRequired) GetParam

func (excludeAllAddressRequired ExcludeAllAddressRequired) GetParam() (string, string)

type ExcludeForiegnAddressRequired

type ExcludeForiegnAddressRequired bool

func (ExcludeForiegnAddressRequired) GetParam

func (excludeForiegnAddressRequired ExcludeForiegnAddressRequired) GetParam() (string, string)

type ExcludeLocalAddressRequired

type ExcludeLocalAddressRequired bool

func (ExcludeLocalAddressRequired) GetParam

func (excludeLocalAddressRequired ExcludeLocalAddressRequired) GetParam() (string, string)

type FallbackMethod

type FallbackMethod string

func (FallbackMethod) GetParam

func (fallbackMethod FallbackMethod) GetParam() (string, string)

type FallbackUrl

type FallbackUrl string

func (FallbackUrl) GetParam

func (fallbackUrl FallbackUrl) GetParam() (string, string)

type FriendlyName

type FriendlyName string

func (FriendlyName) GetParam

func (friendlyName FriendlyName) GetParam() (string, string)

type From

type From string

func (From) GetParam

func (from From) GetParam() (string, string)

type IPChannel

type IPChannel struct {
	Sid          string            `json:"sid"`
	AccountSid   string            `json:"account_sid"`
	ServiceSid   string            `json:"service_sid"`
	FriendlyName string            `json:"friendly_name"`
	UniqueName   string            `json:"unique_name"`
	Attributes   string            `json:"attributes"`
	Type         string            `json:"type"`
	DateCreated  string            `json:"date_created"`
	DateUpdated  string            `json:"date_updated"`
	CreatedBy    string            `json:"created_by"`
	URL          string            `json:"url"`
	Links        map[string]string `json:"links"`
}

IPChannel is a IP Messaging Channel resource.

func GetIPChannel

func GetIPChannel(client *TwilioIPMessagingClient, serviceSid string, sid string) (*IPChannel, error)

GetIPChannel returns the specified IP Channel.

func NewIPChannel

func NewIPChannel(client *TwilioIPMessagingClient, serviceSid string, friendlyName string, uniqueName string, public bool, attributes string) (*IPChannel, error)

NewIPChannel creates a new IP Messaging Channel.

func UpdateIPChannel

func UpdateIPChannel(client *TwilioIPMessagingClient, serviceSid string, sid string, friendlyName string, uniqueName string, public bool, attributes string) (*IPChannel, error)

UpdateIPChannel updates ane existing IP Messaging Channel.

type IPChannelList

type IPChannelList struct {
	Client   Client
	Channels []IPChannel `json:"channels"`
	Meta     Meta        `json:"meta"`
}

IPChannelList gives the results for querying the set of channels. Returns the first page by default.

func ListIPChannels

func ListIPChannels(client *TwilioIPMessagingClient, serviceSid string) (*IPChannelList, error)

ListIPChannels returns the first page of channels.

func (*IPChannelList) FirstPage

func (c *IPChannelList) FirstPage() (*IPChannelList, error)

FirstPage returns the first page of channels.

func (*IPChannelList) GetAllChannels

func (c *IPChannelList) GetAllChannels() ([]IPChannel, error)

GetAllChannels returns all of the channels from all of the pages (from here forward).

func (*IPChannelList) GetChannels

func (c *IPChannelList) GetChannels() []IPChannel

GetChannels recturns the current page of channels.

func (*IPChannelList) HasNextPage

func (c *IPChannelList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of channels.

func (*IPChannelList) HasPreviousPage

func (c *IPChannelList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPChannelList) LastPage

func (c *IPChannelList) LastPage() (*IPChannelList, error)

LastPage returns the last page of channels.

func (*IPChannelList) NextPage

func (c *IPChannelList) NextPage() (*IPChannelList, error)

NextPage returns the next page of channels.

func (*IPChannelList) PreviousPage

func (c *IPChannelList) PreviousPage() (*IPChannelList, error)

PreviousPage returns the previous page of channels.

type IPCredential

type IPCredential struct {
	Sid          string `json:"sid"`
	AccountSid   string `json:"account_sid"`
	FriendlyName string `json:"friendly_name"`
	Type         string `json:"type"` // apn or fcm
	Sandbox      bool   `json:"sandbox"`
	URL          string `json:"url"`
}

IPCredential is a IP Messaging Credential resource.

func GetIPCredential

func GetIPCredential(client *TwilioIPMessagingClient, sid string) (*IPCredential, error)

GetIPCredential returns information on the specified credential.

func NewIPCredential

func NewIPCredential(client *TwilioIPMessagingClient,
	friendlyName, kind string, sandbox bool, apnsCert, apnsPrivateKey, gcmApiKey, fcmSecretKey string) (*IPCredential, error)

NewIPCredential creates a new IP Messaging Credential. Kind must be apns or gcm.

func UpdateIPCredential

func UpdateIPCredential(client *TwilioIPMessagingClient, sid string, friendlyName string, kind string, sandbox bool) (*IPCredential, error)

UpdateIPCredential updates an existing IP Messaging Credential.

func (*IPCredential) UnmarshalJSON

func (cred *IPCredential) UnmarshalJSON(b []byte) error

type IPCredentialList

type IPCredentialList struct {
	Client      Client
	Credentials []IPCredential `json:"credentials"`
	Meta        Meta           `json:"meta"`
}

IPCredentialList gives the results for querying the set of credentials. Returns the first page by default.

func ListIPCredentials

func ListIPCredentials(client *TwilioIPMessagingClient) (*IPCredentialList, error)

ListIPCredentials returns the first page of credentials.

func (*IPCredentialList) FirstPage

func (s *IPCredentialList) FirstPage() (*IPCredentialList, error)

FirstPage returns the first page of credentials.

func (*IPCredentialList) GetAllCredentials

func (s *IPCredentialList) GetAllCredentials() ([]IPCredential, error)

GetAllCredentials returns all of the credentials from all of the pages (from here forward).

func (*IPCredentialList) GetCredentials

func (s *IPCredentialList) GetCredentials() []IPCredential

GetCredentials returns the current page of credentials.

func (*IPCredentialList) HasNextPage

func (s *IPCredentialList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of credentials.

func (*IPCredentialList) HasPreviousPage

func (s *IPCredentialList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPCredentialList) LastPage

func (s *IPCredentialList) LastPage() (*IPCredentialList, error)

LastPage returns the last page of credentials.

func (*IPCredentialList) NextPage

func (s *IPCredentialList) NextPage() (*IPCredentialList, error)

NextPage returns the next page of credentials.

func (*IPCredentialList) PreviousPage

func (s *IPCredentialList) PreviousPage() (*IPCredentialList, error)

PreviousPage returns the previous page of credentials.

type IPMember

type IPMember struct {
	Sid         string  `json:"sid"`
	AccountSid  string  `json:"account_sid"`
	ChannelSid  string  `json:"channel_sid"`
	ServiceSid  string  `json:"service_sid"`
	Identity    string  `json:"identity"`
	RoleSid     *string `json:"role_sid"`
	DateCreated string  `json:"date_created"`
	DateUpdated string  `json:"date_updated"`
	URL         string  `json:"url"`
}

IPMember is a IP Messaging Member resource.

func AddIPMemberToChannel

func AddIPMemberToChannel(client *TwilioIPMessagingClient, serviceSid string, channelSid string, identity string, roleSid string) (*IPMember, error)

AddIPMemberToChannel adds a member to a channel.

func GetIPChannelMember

func GetIPChannelMember(client *TwilioIPMessagingClient, serviceSid, channelSid, sid string) (*IPMember, error)

GetIPChannelMember returns the specified IP Member in the channel.

type IPMemberList

type IPMemberList struct {
	Client  Client
	Members []IPMember `json:"members"`
	Meta    Meta       `json:"meta"`
}

IPMemberList gives the results for querying the set of members. Returns the first page by default.

func ListIPMembers

func ListIPMembers(client *TwilioIPMessagingClient, serviceSid, channelSid string) (*IPMemberList, error)

ListIPMembers returns the first page of members.

func (*IPMemberList) FirstPage

func (c *IPMemberList) FirstPage() (*IPMemberList, error)

FirstPage returns the first page of members.

func (*IPMemberList) GetAllMembers

func (c *IPMemberList) GetAllMembers() ([]IPMember, error)

GetAllMembers returns all of the members from all of the pages (from here forward).

func (*IPMemberList) GetMembers

func (c *IPMemberList) GetMembers() []IPMember

GetMembers recturns the current page of members.

func (*IPMemberList) HasNextPage

func (c *IPMemberList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of members.

func (*IPMemberList) HasPreviousPage

func (c *IPMemberList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPMemberList) LastPage

func (c *IPMemberList) LastPage() (*IPMemberList, error)

LastPage returns the last page of members.

func (*IPMemberList) NextPage

func (c *IPMemberList) NextPage() (*IPMemberList, error)

NextPage returns the next page of members.

func (*IPMemberList) PreviousPage

func (c *IPMemberList) PreviousPage() (*IPMemberList, error)

PreviousPage returns the previous page of members.

type IPMessage

type IPMessage struct {
	Sid         string `json:"sid"`
	AccountSid  string `json:"account_sid"`
	ServiceSid  string `json:"service_sid"`
	To          string `json:"to"` // channel sid
	DateCreated string `json:"date_created"`
	DateUpdated string `json:"date_updated"`
	WasEdited   bool   `json:"was_edited"`
	From        string `json:"from"` // identity
	Body        string `json:"body"`
	URL         string `json:"url"`
}

IPMessage is a IP Messaging Message resource.

func GetIPChannelMessage

func GetIPChannelMessage(client *TwilioIPMessagingClient, serviceSid, channelSid, sid string) (*IPMessage, error)

GetIPChannelMessage returns the specified IP Message in the channel.

func SendIPMessageToChannel

func SendIPMessageToChannel(client *TwilioIPMessagingClient, serviceSid string, channelSid string, from string, body string) (*IPMessage, error)

SendIPMessageToChannel sends a message to a channel.

type IPMessageList

type IPMessageList struct {
	Client   Client
	Messages []IPMessage `json:"messages"`
	Meta     Meta        `json:"meta"`
}

IPMessageList gives the results for querying the set of messages. Returns the first page by default.

func ListIPMessages

func ListIPMessages(client *TwilioIPMessagingClient, serviceSid, channelSid string) (*IPMessageList, error)

ListIPMessages returns the first page of messages for a channel.

func (*IPMessageList) FirstPage

func (c *IPMessageList) FirstPage() (*IPMessageList, error)

FirstPage returns the first page of messages.

func (*IPMessageList) GetAllMessages

func (c *IPMessageList) GetAllMessages() ([]IPMessage, error)

GetAllMessages returns all of the messages from all of the pages (from here forward).

func (*IPMessageList) GetMessages

func (c *IPMessageList) GetMessages() []IPMessage

GetMessages recturns the current page of messages.

func (*IPMessageList) HasNextPage

func (c *IPMessageList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of messages.

func (*IPMessageList) HasPreviousPage

func (c *IPMessageList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPMessageList) LastPage

func (c *IPMessageList) LastPage() (*IPMessageList, error)

LastPage returns the last page of messages.

func (*IPMessageList) NextPage

func (c *IPMessageList) NextPage() (*IPMessageList, error)

NextPage returns the next page of messages.

func (*IPMessageList) PreviousPage

func (c *IPMessageList) PreviousPage() (*IPMessageList, error)

PreviousPage returns the previous page of messages.

type IPRole

type IPRole struct {
	Sid          string   `json:"sid"`
	AccountSid   string   `json:"account_sid"`
	ServiceSid   string   `json:"service_sid"`
	FriendlyName string   `json:"friendly_name"`
	Type         string   `json:"type"`
	Permissions  []string `json:"permissions"`
	DateCreated  string   `json:"date_created"`
	DateUpdated  string   `json:"date_updated"`
	URL          string   `json:"url"`
}

IPRole is a IP Messaging Role resource.

func GetIPRole

func GetIPRole(client *TwilioIPMessagingClient, serviceSid, sid string) (*IPRole, error)

GetIPRole returns information on the specified role.

func NewIPRole

func NewIPRole(client *TwilioIPMessagingClient, serviceSid string, friendlyName string, kind string, permissions []string) (*IPRole, error)

NewIPRole creates a new IP Messaging Role. kind should be "channel" or "service". permissions should be a subset of the permissions consts above.

func UpdateIPRole

func UpdateIPRole(client *TwilioIPMessagingClient, serviceSid string, sid string, friendlyName string, kind string, permissions []string) (*IPRole, error)

UpdateIPRole updates an existing IP Messaging Role.

type IPRoleList

type IPRoleList struct {
	Client *TwilioIPMessagingClient
	Roles  []IPRole `json:"roles"`
	Meta   Meta     `json:"meta"`
}

IPRoleList gives the results for querying the set of roles. Returns the first page by default.

func ListIPRoles

func ListIPRoles(client *TwilioIPMessagingClient, serviceSid string) (*IPRoleList, error)

ListIPRoles returns the first page of roles.

func (*IPRoleList) FirstPage

func (s *IPRoleList) FirstPage() (*IPRoleList, error)

FirstPage returns the first page of roles.

func (*IPRoleList) GetAllRoles

func (s *IPRoleList) GetAllRoles() ([]IPRole, error)

GetAllRoles returns all of the roles from all of the pages (from here forward).

func (*IPRoleList) GetRoles

func (s *IPRoleList) GetRoles() []IPRole

GetRoles returns the current page of roles.

func (*IPRoleList) HasNextPage

func (s *IPRoleList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of roles.

func (*IPRoleList) HasPreviousPage

func (s *IPRoleList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPRoleList) LastPage

func (s *IPRoleList) LastPage() (*IPRoleList, error)

LastPage returns the last page of roles.

func (*IPRoleList) NextPage

func (s *IPRoleList) NextPage() (*IPRoleList, error)

NextPage returns the next page of roles.

func (*IPRoleList) PreviousPage

func (s *IPRoleList) PreviousPage() (*IPRoleList, error)

PreviousPage returns the previous page of roles.

type IPService

type IPService struct {
	Sid                    string            `json:"sid"`
	AccountSid             string            `json:"account_sid"`
	FriendlyName           string            `json:"friendly_name"`
	DateCreated            string            `json:"date_created"`
	DateUpdated            string            `json:"date_updated"`
	DefaultServiceRoleSid  string            `json:"default_service_role_sid"`
	DefaultChannelRoleSid  string            `json:"default_channel_role_sid"`
	TypingIndicatorTimeout uint              `json:"typing_indicator_timeout"`
	Webhooks               map[string]string `json:"webhooks"`
	URL                    string            `json:"url"`
	Links                  map[string]string `json:"links"`
}

IPService is a IP Messaging Service resource.

func GetIPService

func GetIPService(client *TwilioIPMessagingClient, sid string) (*IPService, error)

GetIPService returns information on the specified service.

func NewIPService

func NewIPService(client *TwilioIPMessagingClient, friendlyName string, defaultServiceRoleSid string, defaultChannelRoleSid string,
	typingIndicatorTimeout time.Duration, webhooks Webhooks) (*IPService, error)

NewIPService creates a new IP Messaging Service.

func UpdateIPService

func UpdateIPService(client *TwilioIPMessagingClient, sid string, friendlyName string, defaultServiceRoleSid string, defaultChannelRoleSid string,
	typingIndicatorTimeout time.Duration, webhooks Webhooks) (*IPService, error)

UpdateIPService updates an existing IP Messaging Service.

type IPServiceList

type IPServiceList struct {
	Client   Client
	Services []IPService `json:"services"`
	Meta     Meta        `json:"meta"`
}

IPServiceList gives the results for querying the set of services. Returns the first page by default.

func ListIPServices

func ListIPServices(client *TwilioIPMessagingClient) (*IPServiceList, error)

ListIPServices returns the first page of services.

func (*IPServiceList) FirstPage

func (s *IPServiceList) FirstPage() (*IPServiceList, error)

FirstPage returns the first page of services.

func (*IPServiceList) GetAllServices

func (s *IPServiceList) GetAllServices() ([]IPService, error)

GetAllServices returns all of the services from all of the pages (from here forward).

func (*IPServiceList) GetServices

func (s *IPServiceList) GetServices() []IPService

GetServices returns the current page of services.

func (*IPServiceList) HasNextPage

func (s *IPServiceList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of services.

func (*IPServiceList) HasPreviousPage

func (s *IPServiceList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPServiceList) LastPage

func (s *IPServiceList) LastPage() (*IPServiceList, error)

LastPage returns the last page of services.

func (*IPServiceList) NextPage

func (s *IPServiceList) NextPage() (*IPServiceList, error)

NextPage returns the next page of services.

func (*IPServiceList) PreviousPage

func (s *IPServiceList) PreviousPage() (*IPServiceList, error)

PreviousPage returns the previous page of services.

type IPUser

type IPUser struct {
	Sid         string `json:"sid"`
	AccountSid  string `json:"account_sid"`
	ServiceSid  string `json:"service_sid"`
	RoleSid     string `json:"role_sid"`
	Identity    string `json:"identity"`
	DateCreated string `json:"date_created"`
	DateUpdated string `json:"date_updated"`
	URL         string `json:"url"`
}

IPUser is a IP Messaging User resource.

func GetIPUser

func GetIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) (*IPUser, error)

GetIPUser returns information on the specified user.

func NewIPUser

func NewIPUser(client *TwilioIPMessagingClient, serviceSid string, identity string, roleSid string) (*IPUser, error)

NewIPUser creates a new IP Messaging User.

func UpdateIPUser

func UpdateIPUser(client *TwilioIPMessagingClient, serviceSid string, sid string, identity string, roleSid string) (*IPUser, error)

UpdateIPUser updates an existing IP Messaging user.

type IPUserList

type IPUserList struct {
	Client *TwilioIPMessagingClient
	Users  []IPUser `json:"users"`
	Meta   Meta     `json:"meta"`
}

IPUserList gives the results for querying the set of users. Returns the first page by default.

func ListIPUsers

func ListIPUsers(client *TwilioIPMessagingClient, serviceSid string) (*IPUserList, error)

ListIPUsers returns the first page of users.

func (*IPUserList) FirstPage

func (s *IPUserList) FirstPage() (*IPUserList, error)

FirstPage returns the first page of users.

func (*IPUserList) GetAllUsers

func (s *IPUserList) GetAllUsers() ([]IPUser, error)

GetAllUsers returns all of the users from all of the pages (from here forward).

func (*IPUserList) GetUsers

func (s *IPUserList) GetUsers() []IPUser

GetUsers returns the current page of users.

func (*IPUserList) HasNextPage

func (s *IPUserList) HasNextPage() bool

HasNextPage returns whether or not there is a next page of users.

func (*IPUserList) HasPreviousPage

func (s *IPUserList) HasPreviousPage() bool

HasPreviousPage indicates whether or not there is a previous page of results.

func (*IPUserList) LastPage

func (s *IPUserList) LastPage() (*IPUserList, error)

LastPage returns the last page of users.

func (*IPUserList) NextPage

func (s *IPUserList) NextPage() (*IPUserList, error)

NextPage returns the next page of users.

func (*IPUserList) PreviousPage

func (s *IPUserList) PreviousPage() (*IPUserList, error)

PreviousPage returns the previous page of users.

type IfMachine

type IfMachine string

func (IfMachine) GetParam

func (ifMachine IfMachine) GetParam() (string, string)

type InLata

type InLata string

func (InLata) GetParam

func (inLata InLata) GetParam() (string, string)

type InPostalCode

type InPostalCode string

func (InPostalCode) GetParam

func (inPostalCode InPostalCode) GetParam() (string, string)

type InRateCenter

type InRateCenter string

func (InRateCenter) GetParam

func (inRateCenter InRateCenter) GetParam() (string, string)

type InRegion

type InRegion string

func (InRegion) GetParam

func (inRegion InRegion) GetParam() (string, string)

type IncomingPhoneNumber

type IncomingPhoneNumber struct {
	Sid                  string       `json:"sid"`
	AccountSid           string       `json:"account_sid"`
	FriendlyName         string       `json:"friendly_name"`
	PhoneNumber          string       `json:"phone_number"`
	VoiceUrl             string       `json:"voice_url"`
	VoiceMethod          string       `json:"voice_method"`
	VoiceFallbackUrl     string       `json:"voice_fallback_url"`
	VoiceFallbackMethod  string       `json:"voice_fallback_method"`
	StatusCallback       string       `json:"status_callback"`
	StatusCallbackMethod string       `json:"status_callback_method"`
	VoiceCallerIdLookup  bool         `json:"voice_caller_id_lookup"`
	VoiceApplicationId   string       `json:"voice_application_id"`
	DateCreated          string       `json:"date_created"`
	DateUpdated          string       `json:"date_updated"`
	SmsUrl               string       `json:"sms_url"`
	SmsMethod            string       `json:"sms_method"`
	SmsFallbackUrl       string       `json:"sms_fallback_url"`
	SmsFallbackMethod    string       `json:"sms_fallback_method"`
	SmsApplicationId     string       `json:"sms_application_id"`
	Capabilities         Capabilities `json:"capabilities"`
	ApiVersion           string       `json:"api_version"`
	Uri                  string       `json:"uri"`
}

func BuyPhoneNumber

func BuyPhoneNumber(client Client, number Optional, optionals ...Optional) (*IncomingPhoneNumber, error)

func GetIncomingPhoneNumber

func GetIncomingPhoneNumber(client Client, sid string) (*IncomingPhoneNumber, error)

func UpdatePhoneNumberFields

func UpdatePhoneNumberFields(client Client, number *IncomingPhoneNumber, voiceCallerIdLookup *bool) (*IncomingPhoneNumber, error)

UpdateSetPhoneNumberFields updates any non-empty fields (other than sid) in the passed struct

because pretty much every field can be updated, we assume we are handed a
struct with only the fields that we want to update and the sid nonempty.

Because we can't set the bool VoiceCallerIdLookup to false or true, we must
pass it explicitly as a pointer to true or false, or else leave it nil to leave it alone

type IncomingPhoneNumberList

type IncomingPhoneNumberList struct {
	Client               Client
	Start                int                   `json:"start"`
	Total                int                   `json:"total"`
	NumPages             int                   `json:"num_pages"`
	Page                 int                   `json:"page"`
	PageSize             int                   `json:"page_size"`
	End                  int                   `json:"end"`
	Uri                  string                `json:"uri"`
	FirstPageUri         string                `json:"first_page_uri"`
	LastPageUri          string                `json:"last_page_uri"`
	NextPageUri          string                `json:"next_page_uri"`
	PreviousPageUri      string                `json:"previous_page_uri"`
	IncomingPhoneNumbers []IncomingPhoneNumber `json:"sms_messages"`
}

func GetIncomingPhoneNumberList

func GetIncomingPhoneNumberList(client Client, optionals ...Optional) (*IncomingPhoneNumberList, error)

type IsoCountry

type IsoCountry string

func (IsoCountry) GetParam

func (isoCountry IsoCountry) GetParam() (string, string)

type MediaUrl

type MediaUrl string

func (MediaUrl) GetParam

func (mediaUrl MediaUrl) GetParam() (string, string)

type Message

type Message struct {
	Sid         string `json:"sid"`
	DateCreated string `json:"date_created"`
	DateUpdated string `json:"date_updated"`
	DateSent    string `json:"date_sent"`
	AccountSid  string `json:"account_sid"`
	From        string `json:"from"`
	To          string `json:"to"`
	Body        string `json:"body"`
	NumSegments string `json:"num_segments"`
	Status      string `json:"status"`
	Direction   string `json:"direction"`
	Price       string `json:"price"`
	PriceUnit   string `json:"price_unit"`
	ApiVersion  string `json:"api_version"`
	Uri         string `json:"uri"`
}

func GetMessage

func GetMessage(client Client, sid string) (*Message, error)

func NewMessage

func NewMessage(client Client, from string, to string, content ...Optional) (*Message, error)

type MessageList

type MessageList struct {
	Client          Client
	Start           int       `json:"start"`
	Total           int       `json:"total"`
	NumPages        int       `json:"num_pages"`
	Page            int       `json:"page"`
	PageSize        int       `json:"page_size"`
	End             int       `json:"end"`
	Uri             string    `json:"uri"`
	FirstPageUri    string    `json:"first_page_uri"`
	LastPageUri     string    `json:"last_page_uri"`
	NextPageUri     string    `json:"next_page_uri"`
	PreviousPageUri string    `json:"previous_page_uri"`
	Messages        []Message `json:"sms_messages"`
}

func GetMessageList

func GetMessageList(client Client, optionals ...Optional) (*MessageList, error)

func (*MessageList) FirstPage

func (currentMessageList *MessageList) FirstPage() (*MessageList, error)

func (*MessageList) GetMessages

func (m *MessageList) GetMessages() []Message

func (*MessageList) HasNextPage

func (currentMessageList *MessageList) HasNextPage() bool

func (*MessageList) HasPreviousPage

func (currentMessageList *MessageList) HasPreviousPage() bool

func (*MessageList) LastPage

func (currentMessageList *MessageList) LastPage() (*MessageList, error)

func (*MessageList) NextPage

func (currentMessageList *MessageList) NextPage() (*MessageList, error)

func (*MessageList) PreviousPage

func (currentMessageList *MessageList) PreviousPage() (*MessageList, error)

type MessageStatusCallback

type MessageStatusCallback string

func (MessageStatusCallback) GetParam

func (messageStatusCallback MessageStatusCallback) GetParam() (string, string)

type Meta

type Meta struct {
	Start           int    `json:"start"`
	Total           int    `json:"total"`
	NumPages        int    `json:"num_pages"`
	Page            int    `json:"page"`
	PageSize        int    `json:"page_size"`
	End             int    `json:"end"`
	Uri             string `json:"uri"`
	FirstPageUri    string `json:"first_page_uri"`
	LastPageUri     string `json:"last_page_uri"`
	NextPageUri     string `json:"next_page_uri"`
	PreviousPageUri string `json:"previous_page_uri"`
	Key             string `json:"key"`
}

Meta is a metadata type for the IP messaging services.

type Method

type Method string

func (Method) GetParam

func (method Method) GetParam() (string, string)

type MmsEnabled

type MmsEnabled bool

func (MmsEnabled) GetParam

func (mmsEnabled MmsEnabled) GetParam() (string, string)

type MockClient

type MockClient struct {
	mock.Mock
}

func (*MockClient) AccountSid

func (client *MockClient) AccountSid() string

func (*MockClient) AuthToken

func (client *MockClient) AuthToken() string

func (*MockClient) RootUrl

func (client *MockClient) RootUrl() string

type NearLatLong

type NearLatLong struct {
	Latitude  float64
	Longitude float64
}

func (NearLatLong) GetParam

func (nearLatLong NearLatLong) GetParam() (string, string)

type NearNumber

type NearNumber string

func (NearNumber) GetParam

func (nearNumber NearNumber) GetParam() (string, string)

type Optional

type Optional interface {
	GetParam() (string, string)
}

type ParentCallSid

type ParentCallSid string

func (ParentCallSid) GetParam

func (parentCallSid ParentCallSid) GetParam() (string, string)

type PhoneNumber

type PhoneNumber string

func (PhoneNumber) GetParam

func (phoneNumber PhoneNumber) GetParam() (string, string)

type PostalCode

type PostalCode string

func (PostalCode) GetParam

func (postalcode PostalCode) GetParam() (string, string)

type Record

type Record string

func (Record) GetParam

func (record Record) GetParam() (string, string)

type Region

type Region string

func (Region) GetParam

func (region Region) GetParam() (string, string)

type SendDigits

type SendDigits string

func (SendDigits) GetParam

func (sendDigits SendDigits) GetParam() (string, string)

type SmsApplicationSid

type SmsApplicationSid string

func (SmsApplicationSid) GetParam

func (smsApplicationSid SmsApplicationSid) GetParam() (string, string)

type SmsEnabled

type SmsEnabled bool

func (SmsEnabled) GetParam

func (smsEnabled SmsEnabled) GetParam() (string, string)

type SmsFallbackMethod

type SmsFallbackMethod string

func (SmsFallbackMethod) GetParam

func (smsFallbackMethod SmsFallbackMethod) GetParam() (string, string)

type SmsFallbackUrl

type SmsFallbackUrl string

func (SmsFallbackUrl) GetParam

func (smsFallbackUrl SmsFallbackUrl) GetParam() (string, string)

type SmsStatusCallback

type SmsStatusCallback string

func (SmsStatusCallback) GetParam

func (smsStatusCallback SmsStatusCallback) GetParam() (string, string)

type SmsUrl

type SmsUrl string

func (SmsUrl) GetParam

func (smsUrl SmsUrl) GetParam() (string, string)

type SmsUrlMethod

type SmsUrlMethod string

func (SmsUrlMethod) GetParam

func (smsUrlMethod SmsUrlMethod) GetParam() (string, string)

type StartTime

type StartTime string

func (StartTime) GetParam

func (startTime StartTime) GetParam() (string, string)

type Status

type Status string

func (Status) GetParam

func (status Status) GetParam() (string, string)

type StatusCallback

type StatusCallback string

func (StatusCallback) GetParam

func (statusCallback StatusCallback) GetParam() (string, string)

type StatusCallbackMethod

type StatusCallbackMethod string

func (StatusCallbackMethod) GetParam

func (statusCallbackMethod StatusCallbackMethod) GetParam() (string, string)

type Street

type Street string

func (Street) GetParam

func (street Street) GetParam() (string, string)

type Timeout

type Timeout string

func (Timeout) GetParam

func (timeout Timeout) GetParam() (string, string)

type To

type To string

func (To) GetParam

func (to To) GetParam() (string, string)

type TwilioClient

type TwilioClient struct {
	Timeout    time.Duration
	HttpClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(accountSid, authToken string) *TwilioClient

func (*TwilioClient) AccountSid

func (client *TwilioClient) AccountSid() string

func (*TwilioClient) AuthToken

func (client *TwilioClient) AuthToken() string

func (*TwilioClient) RootUrl

func (client *TwilioClient) RootUrl() string

type TwilioError

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

func (TwilioError) Error

func (e TwilioError) Error() string

type TwilioIPMessagingClient

type TwilioIPMessagingClient struct {
	TwilioClient
}

TwilioIPMessagingClient is used for accessing the Twilio IP Messaging API.

func NewIPMessagingClient

func NewIPMessagingClient(accountSid, authToken string) *TwilioIPMessagingClient

NewIPMessagingClient creates a new Twilio IP Messaging client.

type UsageFilter

type UsageFilter struct {
	Category  string
	StartDate string
	EndDate   string
}

type UsageRecord

type UsageRecord struct {
	Category    string `json:"category"`
	Description string `json:"description"`
	AccountSid  string `json:"account_sid"`
	StartDate   string `json:"start_date"`
	EndDate     string `json:"end_date"`
	Count       string `json:"count"`
	CountUnit   string `json:"count_unit"`
	Usage       string `json:"usage"`
	UsageUnit   string `json:"usage_unit"`
	Price       string `json:"price,omitempty"`
	PriceUnit   string `json:"price_unit"`
	ApiVersion  string `json:"api_version"`
	Uri         string `json:"uri"`
}

UsageRecord contains all data for a Twilio Usage Record

type UsageRecords

type UsageRecords struct {
	FirstPageUri    string        `json:"first_page_uri"`
	End             int           `json:"end"`
	PreviousPageUri string        `json:"previous_page_uri"`
	Uri             string        `json:"uri"`
	PageSize        int           `json:"page_size"`
	Start           int           `json:"start"`
	UsageRecords    []UsageRecord `json:"usage_records"`
}

UsageRecords contains a list of requested UsageRecord's and metadata

func GetUsageAllTime

func GetUsageAllTime(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageDaily

func GetUsageDaily(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageLastMonth

func GetUsageLastMonth(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageMonthly

func GetUsageMonthly(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageNoSubresources

func GetUsageNoSubresources(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageThisMonth

func GetUsageThisMonth(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageToday

func GetUsageToday(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageYearly

func GetUsageYearly(client Client, filter *UsageFilter) (*UsageRecords, error)

func GetUsageYesterday

func GetUsageYesterday(client Client, filter *UsageFilter) (*UsageRecords, error)

type VoiceApplicationSid

type VoiceApplicationSid string

func (VoiceApplicationSid) GetParam

func (voiceApplicationSid VoiceApplicationSid) GetParam() (string, string)

type VoiceEnabled

type VoiceEnabled bool

func (VoiceEnabled) GetParam

func (voiceEnabled VoiceEnabled) GetParam() (string, string)

type VoiceFallbackMethod

type VoiceFallbackMethod string

func (VoiceFallbackMethod) GetParam

func (voiceFallbackMethod VoiceFallbackMethod) GetParam() (string, string)

type VoiceFallbackUrl

type VoiceFallbackUrl string

func (VoiceFallbackUrl) GetParam

func (voiceFallbackUrl VoiceFallbackUrl) GetParam() (string, string)

type VoiceUrl

type VoiceUrl string

Application optionals

func (VoiceUrl) GetParam

func (voiceUrl VoiceUrl) GetParam() (string, string)

type VoiceUrlMethod

type VoiceUrlMethod string

func (VoiceUrlMethod) GetParam

func (voiceUrlMethod VoiceUrlMethod) GetParam() (string, string)

type Webhooks

type Webhooks map[string]string

Webhooks are used to define push webhooks for an IP service.

func NewWebhooks

func NewWebhooks() Webhooks

NewWebhooks creates a new, empty set of web hooks.

func (Webhooks) Add

func (w Webhooks) Add(name, method, format, url string)

Add adds a new webhook. The name should be one of the Webhook* exported values. Method is the HTTP method (e.g., "POST"). Format should be "xml" or "json".

Jump to

Keyboard shortcuts

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