twilio

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 7 Imported by: 387

README

twilio-go

Documentation

The documentation for the Twilio API can be found here.

Supported Go Versions

This library supports the following Go implementations:

  • 1.13.8

Installation

To use twilio-go in your project initialize go modules then run:

go get github.com/twilio/twilio-go@latest

Getting Started

Getting started with the Twilio API couldn't be easier. Create a Client and you're ready to go.

API Credentials

The Twilio Client needs your Twilio credentials. You should pass these directly to the constructor (see the code below).

import "github.com/twilio/twilio-go"

accountSID := "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
authToken := "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
client := twilio.NewClient(s, a)
Buy a phone number
package main
import (
	"fmt"
	"github.com/twilio/twilio-go"
)

func main() {
    accountSID := "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    authToken := "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
    client := twilio.NewClient(accountSID, authToken)
    params := &twilio.IncomingPhoneNumberParams{PhoneNumber:twilio.String("+15017122661")}
    pn, err := client.IncomingPhoneNumbers.Create(params)
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println(pn)
}
Building

To build twilio-go run:

go build
Testing

To execute the test suite run:

go test [-v]
Service Coverage

twilio-go provides clients for:

Code Organization

In general each service's client is implemented in a namesake file (e.g. Chat Service is in chat_service.go) Large services are split between files and will share the same prefix (e.g. taskrouter_activity.go and taskrouter_taskqueue.go). Files for testing are appended with _test (e.g. sync_service_test.go). twilio.go ties the library together by defining the Twilio struct and the Client constructor NewClient.
The Client structure promotes memory reuse between service clients, and provides the baseURL to service clients to allow redirecting requests to non-production domains.

Under the hood the Twilio Client relies on the private functionality within internal/twilio.go. The main functionality is captured by SendRequest and doWithErr. SendRequest and doWithErr facilitate network requests and allow the library to provide an http.Response and error object. SendRequest performs the required encoding and request configuration to comply with Twilio's HTTP standards. Go's built in struct marshalling is not compatible with Twilio's requirements for form encoding so encoding is performed by the form package forked from https://github.com/ajg/form. doWithErr executes the request from SendRequest, parses the error (if any), and returns the result. The error returned by doWithErr may be the Error object, which is meant to parse Twilio-specific error messages from the body of responses to failed requests.

Creating and Updating Resources

All structs for Twilio resources use pointer values for all non-repeated fields. Pointer values allow users to distinguish between unset fields (null) and those set to a zero-value. twilio-go provides helper functions that easily create these pointers for string, bool, float, time, and int values. For example:

// create a new incoming phone number
params := &twilio.IncomingPhoneNumberParams{
    PhoneNumber: twilio.String("+15017122661")
}
p, err := client.IncomingPhoneNumbers.Create(params)

Users who have worked with protocol buffers should find this pattern familiar.

Inspirations and References

While the overall code structure and client interface is modeled after existing Twilio SDKs, we found additional inspiration in some of the following Go SDKs:

These existing SDKs influenced things like our module pattern (using one module instead of breaking everything into separate resource modules) and unit testing strategy.

Behavioral Notes and Future Improvements

Things that we wanted to address had we been given more time:

  • Parameter Validation - twilio-go provides no built-in parameter validation.
  • Enums- Properties that are of an enumberable type are defaulted to a string
  • Retry functionality - There is a 10 second timeout for requests with no retry functionality.
Code Style

The code is styled with go fmt and adheres to Go's Style Guide wherever possible. We use golangci-lint for linting locally and as part of the PR process (this will catch most violations of the above guidelines).

Documentation

Overview

Package twilio provides bindings for Twilio's REST APIs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new bool value to store v and returns a pointer to it.

func Float32

func Float32(v float32) *float32

Float32 is a helper routine that allocates a new float32 value to store v and returns a pointer to it.

func Float64

func Float64(v float64) *float64

Float64 is a helper routine that allocates a new float64 value to store v and returns a pointer to it.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new int value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new int64 value to store v and returns a pointer to it.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Time

func Time(v time.Time) *time.Time

Time is a helper routine that allocates a new time value to store v and returns a pointer to it.

Types

type AvailablePhoneNumberLocal

type AvailablePhoneNumberLocal struct {
	FriendlyName        *string          `json:"friendly_name"`
	PhoneNumber         *string          `json:"phone_number"`
	LATA                *int             `json:"lata,string"`
	Locality            *string          `json:"locality"`
	RateCenter          *string          `json:"rate_center"`
	Latitude            *float64         `json:"latitude,string"`
	Longitude           *float64         `json:"longitude,string"`
	Region              *string          `json:"region"`
	PostalCode          *string          `json:"postal_code"`
	ISOCountry          *string          `json:"iso_country"`
	AddressRequirements *string          `json:"address_requirements"`
	Beta                *bool            `json:"beta"`
	Capabilities        map[string]*bool `json:"capabilities"`
}

AvailablePhoneNumberLocal represents an available local phone number. See: https://www.twilio.com/docs/phone-numbers/api/availablephonenumberlocal-resource

type AvailablePhoneNumberLocalReadParams

type AvailablePhoneNumberLocalReadParams struct {
	// Read on AvailablePhoneNumberLocal requires account_sid in URI
	// Read on AvailablePhoneNumberLocal requires country_code in URI
	FaxEnabled                    *bool   `form:",omitempty"`
	SMSEnabled                    *bool   `form:"SmsEnabled,omitempty"`
	MMSEnabled                    *bool   `form:"MmsEnabled,omitempty"`
	VoiceEnabled                  *bool   `form:",omitempty"`
	ExcludeAllAddressRequired     *bool   `form:",omitempty"`
	ExcludeLocalAddressRequired   *bool   `form:",omitempty"`
	ExcludeForeignAddressRequired *bool   `form:",omitempty"`
	Beta                          *bool   `form:",omitempty"`
	Distance                      *int    `form:",omitempty"`
	AreaCode                      *int    `form:",omitempty"`
	InPostalCode                  *string `form:",omitempty"`
	NearNumber                    *string `form:",omitempty"`
	NearLatLong                   *string `form:",omitempty"`
	Contains                      *string `form:",omitempty"`
	InRegion                      *string `form:",omitempty"`
	InRateCenter                  *string `form:",omitempty"`
	InLATA                        *string `form:"InLata,omitempty"`
	InLocality                    *string `form:",omitempty"`
}

AvailablePhoneNumberLocalReadParams is the set of parameters that can be used during a local phonenumber search.

type AvailablePhoneNumbersLocal

type AvailablePhoneNumbersLocal struct {
	NumPages              *int                         `json:"num_pages"`
	Page                  *int                         `json:"page"`
	PageSize              *int                         `json:"page_size"`
	Start                 *int                         `json:"start"`
	Total                 *int                         `json:"total"`
	End                   *int                         `json:"end"`
	FirstPageURI          *string                      `json:"first_page_uri"`
	LastPageURI           *string                      `json:"last_page_uri"`
	NextPageURI           *string                      `json:"next_page_uri"`
	URI                   *string                      `json:"uri"`
	PreviousPageURI       *string                      `json:"previous_page_uri"`
	AvailablePhoneNumbers []*AvailablePhoneNumberLocal `json:"available_phone_numbers"`
}

AvailablePhoneNumbersLocal represents a paginated set of AvailablePhoneNumberLocal structs.

type BaseNotification

type BaseNotification struct {
	Enabled  *bool   `json:"enabled" form:",omitempty"`
	Template *string `json:"template" form:",omitempty"`
	Sound    *string `json:"sound" form:",omitempty"`
}

BaseNotification sets push notification settings for the following types of notifications: Added to Channel, Invited to Channel, Removed from Channel.

type ChatRole

type ChatRole 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  *time.Time `json:"date_created"`
	DateUpdated  *time.Time `json:"date_updated"`
	URL          *string    `json:"url"`
}

ChatRole represents what a user can do within a Chat Service instance. See: https://www.twilio.com/docs/chat/rest/role-resource

type ChatRoleParams

type ChatRoleParams struct {
	FriendlyName *string   `form:",omitempty"`
	Type         *string   `form:",omitempty"`
	Permission   []*string `form:",omitempty"`
}

ChatRoleParams is the set of parameters that can be used when creating or updating a Chat Role.

type ChatRoles

type ChatRoles struct {
	Meta  *Meta `json:"meta"`
	Roles []*ChatRole
}

ChatRoles represents a paginated set of Chat Role structs.

type ChatService

type ChatService struct {
	SID                          *string            `json:"sid"`
	AccountSID                   *string            `json:"account_sid"`
	FriendlyName                 *string            `json:"friendly_name"`
	DateCreated                  *time.Time         `json:"date_created"`
	DateUpdated                  *time.Time         `json:"date_updated"`
	DefaultServiceRoleSID        *string            `json:"default_service_role_sid"`
	DefaultChannelRoleSID        *string            `json:"default_channel_role_sid"`
	DefaultChannelCreatorRoleSID *string            `json:"default_channel_creator_role_sid"`
	ReadStatusEnabled            *bool              `json:"read_status_enabled"`
	ReachabilityEnabled          *bool              `json:"reachability_enabled"`
	TypingIndicatorTimeout       *int               `json:"typing_indicator_timeout"`
	ConsumptionReportInterval    *int               `json:"consumption_report_interval"`
	Limits                       map[string]*int    `json:"limits"`
	PreWebhookURL                *string            `json:"pre_webhook_url"`
	PostWebhookURL               *string            `json:"post_webhook_url"`
	WebhookMethod                *string            `json:"webhook_method"`
	WebhookFilters               []*string          `json:"webhook_filters"`
	PreWebhookRetryCount         *int               `json:"pre_webhook_retry_count"`
	PostWebhookRetryCount        *int               `json:"post_webhook_retry_count"`
	Notifications                *Notifications     `json:"notifications,omitempty"`
	Media                        *Media             `json:"media"`
	URL                          *string            `json:"url"`
	Links                        map[string]*string `json:"links"`
}

ChatService is the top-level scope of all other resources in the Programmable Chat REST API. All other Programmable Chat resources belong to a specific Service. See: https://www.twilio.com/docs/chat/rest/service-resource

type ChatServiceList

type ChatServiceList struct {
	Meta     *Meta          `json:"meta"`
	Services []*ChatService `json:"services"`
}

ChatServiceList is the API response for reading multiple Chat Services

type ChatServiceParams

type ChatServiceParams struct {
	FriendlyName                 *string         `form:",omitempty"`
	DefaultServiceRoleSID        *string         `form:"DefaultServiceRoleSid,omitempty"`
	DefaultChannelRoleSID        *string         `form:"DefaultChannelRoleSid,omitempty"`
	DefaultChannelCreatorRoleSID *string         `form:"DefaultChannelCreatorRoleSid,omitempty"`
	ReadStatusEnabled            *bool           `form:",omitempty"`
	ReachabilityEnabled          *bool           `form:",omitempty"`
	TypingIndicatorTimeout       *int            `form:",omitempty"`
	ConsumptionReportInterval    *int            `form:",omitempty"`
	Notifications                *Notifications  `form:",omitempty"`
	PreWebhookURL                *string         `form:"PreWebhookUrl,omitempty"`
	PostWebhookURL               *string         `form:"PostWebhookUrl,omitempty"`
	WebhookMethod                *string         `form:",omitempty"`
	WebhookFilters               []*string       `form:",omitempty"`
	PreWebhookRetryCount         *int            `form:",omitempty"`
	PostWebhookRetryCount        *int            `form:",omitempty"`
	Limits                       map[string]*int `form:",omitempty"`
}

ChatServiceParams is the set of parameters that can be used when creating or updating a service.

type FlexFlow

type FlexFlow struct {
	AccountSID      *string      `json:"account_sid"`
	DateCreated     *time.Time   `json:"date_created"`
	DateUpdated     *time.Time   `json:"date_updated"`
	SID             *string      `json:"sid"`
	FriendlyName    *string      `json:"friendly_name"`
	ChatServiceSID  *string      `json:"chat_service_sid"`
	ChannelType     *string      `json:"channel_type"`
	ContactIdentity *string      `json:"contact_identity"`
	Enabled         *bool        `json:"enabled"`
	IntegrationType *string      `json:"integration_type"`
	Integration     *Integration `json:"integration"`
	LongLived       *bool        `json:"long_lived"`
	JanitorEnabled  *bool        `json:"janitor_enabled"`
	URL             *string      `json:"url"`
}

A FlexFlow is the logic linking a Messaging Channel, like SMS, to Flex. See: https://www.twilio.com/docs/flex/flow

type FlexFlowList

type FlexFlowList struct {
	FlexFlows []*FlexFlow `json:"flex_flows"`
	Meta      *Meta       `json:"meta"`
}

FlexFlowList is the API response for reading multiple Proxy Services.

type FlexFlowParams

type FlexFlowParams struct {
	FriendlyName    *string      `form:",omitempty"`
	Priority        *int         `form:",omitempty"`
	ChatServiceSID  *string      `form:"ChatServiceSid,omitempty"`
	ChannelType     *string      `form:",omitempty"`
	ContactIdentity *string      `form:",omitempty"`
	Enabled         *bool        `form:",omitempty"`
	IntegrationType *string      `form:",omitempty"`
	Integration     *Integration `form:",omitempty"`
	LongLived       *bool        `form:",omitempty"`
	JanitorEnabled  *bool        `form:",omitempty"`
	URL             *string      `form:"Url,omitempty"`
}

FlexFlowParams is the set of parameters that can be used when creating or updating a Flex Flow.

type IncomingPhoneNumber

type IncomingPhoneNumber struct {
	Beta                 *bool            `json:"beta"`
	VoiceCallerIDLookup  *bool            `json:"voice_caller_id_lookup"`
	AccountSID           *string          `json:"account_sid"`
	AddressSID           *string          `json:"address_sid"`
	AddressRequirements  *string          `json:"address_requirements"`
	APIVersion           *string          `json:"api_version"`
	Capabilities         map[string]*bool `json:"capabilities"`
	DateCreated          *string          `json:"date_created"`
	DateUpdated          *string          `json:"date_updated"`
	FriendlyName         *string          `json:"friendly_name"`
	IdentitySID          *string          `json:"identity_sid"`
	PhoneNumber          *string          `json:"phone_number"`
	Origin               *string          `json:"origin"`
	SID                  *string          `json:"sid"`
	SMSApplicationSID    *string          `json:"sms_application_sid"`
	SMSFallbackMethod    *string          `json:"sms_fallback_method"`
	SMSFallbackURL       *string          `json:"sms_fallback_url"`
	SMSMethod            *string          `json:"sms_method"`
	SMSURL               *string          `json:"sms_url"`
	StatusCallback       *string          `json:"status_callback"`
	StatusCallbackMethod *string          `json:"status_callback_method"`
	TrunkSID             *string          `json:"trunk_sid"`
	URI                  *string          `json:"uri"`
	VoiceApplicationSID  *string          `json:"voice_application_sid"`
	VoiceFallbackMethod  *string          `json:"voice_fallback_method"`
	VoiceFallbackURL     *string          `json:"voice_fallback_url"`
	VoiceMethod          *string          `json:"voice_method"`
	VoiceURL             *string          `json:"voice_url"`
	EmergencyStatus      *string          `json:"emergency_status"`
	EmergencyAddressSID  *string          `json:"emergency_address_sid"`
	BundleSID            *string          `json:"bundle_sid"`
}

IncomingPhoneNumber represents a Twilio phone number provisioned from Twilio, ported or hosted to Twilio. See: https://www.twilio.com/docs/phone-numbers/api/incomingphonenumber-resource

type IncomingPhoneNumberParams

type IncomingPhoneNumberParams struct {
	APIVersion           *string `form:"ApiVersion,omitempty"`
	FriendlyName         *string `form:",omitempty"`
	SMSApplicationSID    *string `form:"SmsApplicationSid,omitempty"`
	SMSFallbackMethod    *string `form:"SmsFallbackMethod,omitempty"`
	PhoneNumber          *string `form:",omitempty"`
	AreaCode             *string `form:",omitempty"`
	SMSFallbackURL       *string `form:"SmsFallbackUrl,omitempty"`
	SMSMethod            *string `form:"SmsMethod,omitempty"`
	SMSURL               *string `form:"SmsUrl,omitempty"`
	StatusCallback       *string `form:",omitempty"`
	AddressSID           *string `form:"AddressSid,omitempty"`
	StatusCallbackMethod *string `form:",omitempty"`
	VoiceApplicationSID  *string `form:"VoiceApplicationSid,omitempty"`
	VoiceCallerIDLookup  *bool   `form:"VoiceCallerIdLookup,omitempty"`
	VoiceFallbackMethod  *string `form:",omitempty"`
	VoiceFallbackURL     *string `form:"VoiceFallbackUrl,omitempty"`
	VoiceMethod          *string `form:",omitempty"`
	VoiceURL             *string `form:"VoiceUrl,omitempty"`
	VoiceReceiveMode     *string `form:",omitempty"`
	EmergencyStatus      *string `form:",omitempty"`
	EmergencyAddressSID  *string `form:"EmergencyAddressSid,omitempty"`
	BundleSID            *string `form:"BundleSid,omitempty"`
	IdentitySID          *string `form:"IdentitySid,omitempty"`
	TrunkSID             *string `form:"TrunkSid,omitempty"`
}

IncomingPhoneNumberParams is the set of parameters that can be used when creating or updating an Incoming Phone Number.

type Integration

type Integration struct {
	WorkspaceSID      *string `json:"workspace_sid" form:"WorkspaceSid,omitempty"`
	WorkflowSID       *string `json:"workflow_sid" form:"WorkflowSid,omitempty"`
	Channel           *string `json:"channel" form:",omitempty"`
	Timeout           *int    `json:"timeout" form:",omitempty"`
	FlowSID           *string `json:"flow_sid" form:"FlowSid,omitempty"`
	RetryCount        *int    `json:"retry_count" form:",omitempty"`
	Priority          *int    `json:"priority" form:",omitempty"`
	CreationOnMessage *bool   `json:"creation_on_message" form:",omitempty"`
}

An Integration represents a connection to Studio flow, TaskRouter task, or external webhook.

type Media

type Media struct {
	SizeLimitMB          *int    `json:"size_limit_mb"`
	CompatibilityMessage *string `json:"compatibility_message"`
}

Media describes the properties of media that the service supports.

type Meta

type Meta struct {
	FirstPageURL    *string `json:"first_page_url"`
	Key             *string `json:"key"`
	LastPageURL     *string `json:"last_page_url,omitempty"`
	NextPageURL     *string `json:"next_page_url"`
	Page            *int    `json:"page"`
	PageSize        *int    `json:"page_size"`
	PreviousPageURL *string `json:"previous_page_url"`
	URL             *string `json:"url"`
}

Meta holds relevant pagination resources.

type NewMessage

type NewMessage struct {
	Enabled           *bool   `json:"enabled" form:",omitempty"`
	Template          *string `json:"template" form:",omitempty"`
	Sound             *string `json:"sound" form:",omitempty"`
	BadgeCountEnabled *bool   `json:"badge_count_enabled" form:",omitempty"`
}

NewMessage sets push notification settings for when a new Message is posted to the Channel.

type Notifications

type Notifications struct {
	RemovedFromChannel *BaseNotification `json:"removed_from_channel" form:",omitempty"`
	LogEnabled         *bool             `json:"log_enabled" form:",omitempty"`
	AddedToChannel     *BaseNotification `json:"added_to_channel" form:",omitempty"`
	NewMessage         *NewMessage       `json:"new_message" form:",omitempty"`
	InvitedToChannel   *BaseNotification `json:"invited_to_channel" form:",omitempty"`
}

Notifications describes the enabled notification state of the Chat Service.

type ProxyPhoneNumber

type ProxyPhoneNumber struct {
	SID             *string          `json:"sid"`
	AccountSID      *string          `json:"account_sid"`
	ProxyServiceSID *string          `json:"service_sid"`
	DateCreated     *time.Time       `json:"date_created"`
	DateUpdated     *time.Time       `json:"date_updated"`
	PhoneNumber     *string          `json:"phone_number"`
	FriendlyName    *string          `json:"friendly_name"`
	ISOCountry      *string          `json:"iso_country"`
	Capabilities    map[string]*bool `json:"capabilities"`
	URL             *string          `json:"url"`
	IsReserved      *bool            `json:"is_reserved"`
	InUse           *int             `json:"in_use"`
}

ProxyPhoneNumber represents a Twilio phone number provisioned from Twilio, ported or hosted to Twilio. See: https://www.twilio.com/docs/proxy/api/phone-number

type ProxyPhoneNumberCreateParams

type ProxyPhoneNumberCreateParams struct {
	PhoneNumberSID *string `form:"Sid,omitempty"`
	IsReserved     *bool   `form:"IsReserved,omitempty"`
	PhoneNumber    *string `form:"PhoneNumber,omitempty"`
}

ProxyPhoneNumberCreateParams is the set of parameters that can be used when creating a Proxy Phone Number.

type ProxyPhoneNumberList

type ProxyPhoneNumberList struct {
	PhoneNumbers []*ProxyPhoneNumber `json:"phone_numbers"`
	Meta         *Meta               `json:"meta"`
}

ProxyPhoneNumberList is the API response for reading multiple Proxy Phone Numbers

type ProxyPhoneNumberUpdateParams

type ProxyPhoneNumberUpdateParams struct {
	PhoneNumberSID *string `url:"Sid,omitempty"`
	IsReserved     *bool   `url:"IsReserved,omitempty"`
}

ProxyPhoneNumberUpdateParams is the set of parameters that can be used when updating updating a Proxy Phone Number.

type ProxyService

type ProxyService struct {
	SID                     *string            `json:"sid"`
	AccountSID              *string            `json:"account_sid"`
	ChatInstanceSID         *string            `json:"chat_instance_sid"`
	UniqueName              *string            `json:"unique_name"`
	DefaultTTL              *int               `json:"default_ttl"`
	CallbackURL             *string            `json:"callback_url"`
	GeoMatchLevel           *string            `json:"geo_match_level"`
	NumberSelectionBehavior *string            `json:"number_selection_behavior"`
	InterceptCallbackURL    *string            `json:"intercept_callback_url"`
	OutOfSessionCallbackURL *string            `json:"out_of_session_callback_url"`
	DateCreated             *time.Time         `json:"date_created"`
	DateUpdated             *time.Time         `json:"date_updated"`
	URL                     *string            `json:"url"`
	Links                   map[string]*string `json:"links"`
}

ProxyService is the top-level scope of all other resources in the Programmable Proxy REST API. All other Programmable Proxy resources belong to a specific Service. See: https://www.twilio.com/docs/proxy/api/service

type ProxyServiceList

type ProxyServiceList struct {
	Service []*ProxyService `json:"service"`
	Meta    *Meta           `json:"meta"`
}

ProxyServiceList is the API response for reading multiple Proxy Services

type ProxyServiceParams

type ProxyServiceParams struct {
	ChatInstanceSID         *string `form:"ChatInstanceSid,omitempty"`
	UniqueName              *string `form:",omitempty"`
	DefaultTTL              *int    `form:"DefaultTtl,omitempty"`
	CallbackURL             *string `form:"CallbackUrl,omitempty"`
	GeoMatchLevel           *string `form:",omitempty"`
	NumberSelectionBehavior *string `form:",omitempty"`
	InterceptCallbackURL    *string `form:"InterceptCallbackUrl,omitempty"`
	OutOfSessionCallbackURL *string `form:"OutOfSessionCallbackUrl,omitempty"`
}

ProxyServiceParams is the set of parameters that can be used when creating or updating a service.

type RuntimeEnvironment

type RuntimeEnvironment struct {
	SID          *string            `json:"sid"`
	AccountSID   *string            `json:"account_sid"`
	ServiceSID   *string            `json:"service_sid"`
	BuildSID     *string            `json:"build_sid"`
	UniqueName   *string            `json:"unique_name"`
	DomainName   *string            `json:"domain_name"`
	DomainSuffix *string            `json:"domain_suffix"`
	DateCreated  *time.Time         `json:"date_created"`
	DateUpdated  *time.Time         `json:"date_updated"`
	URL          *string            `json:"url"`
	Links        map[string]*string `json:"links"`
}

RuntimeEnvironment defines the different domains your Functions and Assets are available under. See: https://www.twilio.com/docs/runtime/functions-assets-api/api/environment

type RuntimeEnvironmentList

type RuntimeEnvironmentList struct {
	Environments []*RuntimeEnvironment `json:"environments"`
	Meta         *Meta                 `json:"meta"`
}

RuntimeEnvironmentList is the API response for reading multiple Runtime Environments.

type RuntimeEnvironmentParams

type RuntimeEnvironmentParams struct {
	UniqueName   *string `form:",omitempty"`
	DomainSuffix *string `form:",omitempty"`
}

RuntimeEnvironmentParams is the set of parameters that can be used when creating a Runtime Environment.

type RuntimeService

type RuntimeService struct {
	SID                *string            `json:"sid"`
	AccountSID         *string            `json:"account_sid"`
	UniqueName         *string            `json:"unique_name"`
	FriendlyName       *string            `json:"friendly_name"`
	IncludeCredentials *bool              `json:"include_credentials"`
	DateCreated        *time.Time         `json:"date_created"`
	DateUpdated        *time.Time         `json:"date_updated"`
	URL                *string            `json:"url"`
	Links              map[string]*string `json:"links"`
}

RuntimeService is the top-level scope of all other resources in the Programmable Runtime REST API. All other Programmable Runtime resources belong to a specific Service. See: https://www.twilio.com/docs/runtime/functions-assets-api/api/service

type RuntimeServiceList

type RuntimeServiceList struct {
	Service []*RuntimeService `json:"services"`
	Meta    *Meta             `json:"meta"`
}

RuntimeServiceList is the API response for reading multiple Runtime Services.

type RuntimeServiceParams

type RuntimeServiceParams struct {
	UniqueName         *string `form:",omitempty"`
	FriendlyName       *string `form:",omitempty"`
	IncludeCredentials *bool   `form:",omitempty"`
}

RuntimeServiceParams is the set of parameters that can be used when creating or updating a service.

type StudioFlow

type StudioFlow struct {
	SID           *string            `json:"sid"`
	AccountSID    *string            `json:"account_sid"`
	FriendlyName  *string            `json:"friendly_name"`
	Definition    *interface{}       `json:"definition"`
	Status        *string            `json:"status"`
	Revision      *int               `json:"revision"`
	CommitMessage *string            `json:"commit_message"`
	Errors        *interface{}       `json:"errors"`
	DateCreated   *time.Time         `json:"date_created"`
	DateUpdated   *time.Time         `json:"date_updated"`
	URL           *string            `json:"url"`
	Valid         *bool              `json:"valid"`
	WebhookURL    *string            `json:"webhook_url"`
	Links         map[string]*string `json:"links"`
}

StudioFlow are individual workflows that you create. Flow definitions are expressed as instances of a JSON schema. See: https://www.twilio.com/docs/studio/rest-api/v2/flow

type StudioFlowParams

type StudioFlowParams struct {
	FriendlyName  *string `form:",omitempty"`
	Status        *string `form:",omitempty"`
	Definition    *string `form:",omitempty"`
	CommitMessage *string `form:",omitempty"`
}

StudioFlowParams is the set of parameters that can be used when creating or updating a service.

type SyncService

type SyncService struct {
	SID                           *string            `json:"sid"`
	AccountSID                    *string            `json:"account_sid"`
	UniqueName                    *string            `json:"unique_name"`
	FriendlyName                  *string            `json:"friendly_name"`
	DateCreated                   *time.Time         `json:"date_created"`
	DateUpdated                   *time.Time         `json:"date_updated"`
	URL                           *string            `json:"url"`
	Links                         map[string]*string `json:"links"`
	WebhookURL                    *string            `json:"webhook_url"`
	WebhooksFromRestEnabled       *bool              `json:"webhooks_from_rest_enabled"`
	ReachabilityWebhooksEnabled   *bool              `json:"reachability_webhooks_enabled"`
	ACLEnabled                    *bool              `json:"acl_enabled"`
	ReachabilityDebouncingEnabled *bool              `json:"reachability_debouncing_enabled"`
	ReachabilityDebouncingWindow  *int               `json:"reachability_debouncing_window"`
}

SyncService is the top-level scope of all other resources in the Sync REST API. See: https://www.twilio.com/docs/sync/api/service

type SyncServiceList

type SyncServiceList struct {
	Service []*SyncService `json:"services"`
	Meta    *Meta          `json:"meta"`
}

SyncServiceList is the API response for reading multiple Sync Services.

type SyncServiceParams

type SyncServiceParams struct {
	FriendlyName                  *string `form:",omitempty"`
	WebhookURL                    *string `form:"WebhookUrl,omitempty"`
	ReachabilityWebhooksEnabled   *bool   `form:",omitempty"`
	ACLEnabled                    *bool   `form:"AclEnabled,omitempty"`
	ReachabilityDebouncingEnabled *bool   `form:",omitempty"`
	ReachabilityDebouncingWindow  *int    `form:",omitempty"`
	WebhooksFromRestEnabled       *bool   `form:",omitempty"`
}

SyncServiceParams is the set of parameters that can be used when creating or updating a service.

type TaskRouterActivity

type TaskRouterActivity struct {
	AccountSID   *string    `json:"account_sid"`
	Available    *bool      `json:"available"`
	DateCreated  *time.Time `json:"date_created"`
	DateUpdated  *time.Time `json:"date_updated"`
	FriendlyName *string    `json:"friendly_name"`
	SID          *string    `json:"sid"`
	WorkspaceSID *string    `json:"workspace_sid"`
	URL          *string    `json:"url"`
}

TaskRouterActivity describes the current status of a Worker, which determines whether they are eligible to receive task assignments. refer: https://www.twilio.com/docs/taskrouter/api/activity

type TaskRouterActivityList

type TaskRouterActivityList struct {
	Activities []*TaskRouterActivity `json:"activities"`
	Meta       *Meta                 `json:"meta,omitempty"`
}

TaskRouterActivityList struct to parse response of activity read.

type TaskRouterActivityParams

type TaskRouterActivityParams struct {
	Available    *bool   `form:",omitempty"`
	FriendlyName *string `form:",omitempty"`
}

TaskRouterActivityParams activity params to create/update activity.

type TaskRouterActivityQueryParams

type TaskRouterActivityQueryParams struct {
	FriendlyName *string `form:",omitempty"`
	Available    *string `form:",omitempty"`
	PageSize     *int    `form:",omitempty"`
}

TaskRouterActivityQueryParams query params to read workspaces.

type TaskRouterTaskQueue

type TaskRouterTaskQueue struct {
	AccountSID              *string            `json:"account_sid"`
	AssignmentActivitySID   *string            `json:"assignment_activity_sid"`
	AssignmentActivityName  *string            `json:"assignment_activity_name"`
	DateCreated             *time.Time         `json:"date_created"`
	DateUpdated             *time.Time         `json:"date_updated"`
	FriendlyName            *string            `json:"friendly_name"`
	MaxReservedWorkers      *int               `json:"max_reserved_workers"`
	ReservationActivitySID  *string            `json:"reservation_activity_sid"`
	ReservationActivityName *string            `json:"reservation_activity_name"`
	SID                     *string            `json:"sid"`
	TargetWorkers           *string            `json:"target_workers"`
	TaskOrder               *string            `json:"task_order"`
	URL                     *string            `json:"url"`
	WorkspaceSID            *string            `json:"workspace_sid"`
	Links                   map[string]*string `json:"links"`
}

TaskRouterTaskQueue allow you to categorize Tasks and describe which Workers are eligible to handle those Tasks. refer: https://www.twilio.com/docs/taskrouter/api/task-queue

type TaskRouterTaskQueueList

type TaskRouterTaskQueueList struct {
	TaskQueues []*TaskRouterTaskQueue `json:"task_queues"`
	Meta       *Meta                  `json:"meta,omitempty"`
}

TaskRouterTaskQueueList struct to parse response of taskRouterTaskqueue read.

type TaskRouterTaskQueueParams

type TaskRouterTaskQueueParams struct {
	FriendlyName           *string `form:",omitempty"`
	AssignmentActivitySID  *string `form:"AssignmentActivitySid,omitempty"`
	MaxReservedWorkers     *int    `form:",omitempty"`
	TargetWorkers          *string `form:",omitempty"`
	TaskOrder              *string `form:"TaskOrder,omitempty"`
	ReservationActivitySID *string `form:"ReservationActivitySid,omitempty"`
}

TaskRouterTaskQueueParams taskRouterTaskQueue parameters.

type TaskRouterTaskQueueQueryParams

type TaskRouterTaskQueueQueryParams struct {
	FriendlyName             *string `form:"FriendlyName,omitempty"`
	EvaluateWorkerAttributes *string `form:"EvaluateWorkerAttributes,omitempty"`
	PageSize                 *int    `form:"PageSize,omitempty"`
}

TaskRouterTaskQueueQueryParams query params to read TaskQueues.

type TaskRouterWorkflow

type TaskRouterWorkflow struct {
	AssignmentCallbackURL         *string            `json:"assignment_callback_url"`
	Configuration                 *string            `json:"configuration"`
	AccountSID                    *string            `json:"account_sid"`
	DateCreated                   *time.Time         `json:"date_created"`
	DateUpdated                   *time.Time         `json:"date_updated"`
	DocumentContentType           *string            `json:"document_content_type"`
	FallbackAssignmentCallbackURL *string            `json:"fallback_assignment_callback_url"`
	FriendlyName                  *string            `json:"friendly_name"`
	SID                           *string            `json:"sid"`
	TaskReservationTimeout        *int               `json:"task_reservation_timeout"`
	WorkspaceSID                  *string            `json:"workspace_sid"`
	URL                           *string            `json:"url"`
	Links                         map[string]*string `json:"links"`
}

TaskRouterWorkflow controls how tasks will be prioritized and routed into Queues, and how Tasks should escalate in priority or move across queues over time. refer: https://www.twilio.com/docs/taskrouter/api/workflow.

type TaskRouterWorkflowList

type TaskRouterWorkflowList struct {
	Workflows []*TaskRouterWorkflow `json:"workflows"`
	Meta      *Meta                 `json:"meta,omitempty"`
}

TaskRouterWorkflowList struct to parse response of workspace read.

type TaskRouterWorkflowParams

type TaskRouterWorkflowParams struct {
	FriendlyName                  *string `form:",omitempty"`
	Configuration                 *string `form:",omitempty"`
	AssignmentCallbackURL         *string `form:"AssignmentCallbackUrl,omitempty"`
	FallbackAssignmentCallbackURL *string `form:"FallbackAssignmentCallbackUrl,omitempty"`
	TaskReservationTimeout        *int    `form:",omitempty"`
}

TaskRouterWorkflowParams TaskRouterWorkflow parameters.

type TaskRouterWorkflowQueryParams

type TaskRouterWorkflowQueryParams struct {
	FriendlyName *string `form:",omitempty"`
	PageSize     *int    `form:",omitempty"`
}

TaskRouterWorkflowQueryParams query params to read workspaces.

type TaskRouterWorkspace

type TaskRouterWorkspace struct {
	SID                  *string            `json:"sid"`
	AccountSID           *string            `json:"account_sid"`
	DateCreated          *time.Time         `json:"date_created"`
	DateUpdated          *time.Time         `json:"date_updated"`
	DefaultActivityName  *string            `json:"default_activity_name"`
	DefaultActivitySID   *string            `json:"default_activity_sid"`
	TimeoutActivityName  *string            `json:"timeout_activity_name"`
	TimeoutActivitySID   *string            `json:"timeout_activity_sid"`
	URL                  *string            `json:"url"`
	Links                map[string]*string `json:"links"`
	FriendlyName         *string            `json:"friendly_name"`
	EventCallbackURL     *string            `json:"event_callback_url"`
	EventsFilter         *string            `json:"events_filter"`
	MultitaskEnabled     *bool              `json:"multi_task_enabled"`
	Template             *string            `json:"template"`
	PrioritizeQueueOrder *string            `json:"prioritize_queue_order"`
}

A TaskRouterWorkspace is a container for your Tasks, Workers, TaskQueues, Workflows, and Activities. refer: https://www.twilio.com/docs/taskrouter/api/workspace.

type TaskRouterWorkspaceList

type TaskRouterWorkspaceList struct {
	Workspaces []*TaskRouterWorkspace `json:"workspaces"`
	Meta       *Meta                  `json:"meta,omitempty"`
}

TaskRouterWorkspaceList struct to parse response of TaskRouterWorkspace read.

type TaskRouterWorkspaceParams

type TaskRouterWorkspaceParams struct {
	FriendlyName         *string `form:"FriendlyName,omitempty"`
	EventCallbackURL     *string `form:"EventCallbackUrl,omitempty"`
	EventsFilter         *string `form:"EventsFilter,omitempty"`
	MultitaskEnabled     *bool   `form:"MultitaskEnabled,omitempty"`
	Template             *string `form:"Template,omitempty"`
	PrioritizeQueueOrder *string `form:"PrioritizeQueueOrder,omitempty"`
}

TaskRouterWorkspaceParams TaskRouterWorkspace params for CRUD.

type TaskRouterWorkspaceQueryParams

type TaskRouterWorkspaceQueryParams struct {
	FriendlyName *string `form:"FriendlyName,omitempty"`
	PageSize     *int    `form:"PageSize,omitempty"`
}

TaskRouterWorkspaceQueryParams query params to read TaskRouterWorkspaces.

type Twilio

type Twilio struct {
	*twilio.Credentials
	*twilio.Client

	Chat                  *chatClient
	Proxy                 *proxyClient
	TaskRouter            *taskRouterClient
	Studio                *studioClient
	AvailablePhoneNumbers *availablePhoneNumbersClient
	IncomingPhoneNumbers  *incomingPhoneNumberClient
	FlexFlow              *flexFlowClient
	Sync                  *syncClient
	Serverless            *serverlessClient
	// contains filtered or unexported fields
}

Twilio provides access to Twilio services.

func NewClient

func NewClient(accountSID string, authToken string) *Twilio

NewClient provides an initialized Twilio client.

Directories

Path Synopsis
client module
Package twilio provides internal utilities for the twilio-go client library.
Package twilio provides internal utilities for the twilio-go client library.

Jump to

Keyboard shortcuts

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