bandwidth

package module
v0.0.0-...-7566556 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 13 Imported by: 2

README

Bandwidth HTTP Voice & v1 Messaging SDK GoDoc Build Status

Deprecation Notice

This project is deprecated.

Bandwidth HTTP Voice & v1 Messaging Go SDK

Notice: As of April 2019, versions of go-bandwidth less than 1.0.0 will not be compatible with Bandwidth's V2 Messaging. If you are using Bandwidth's V2 Messaging, you will need to update your go-bandwidth package version to 1.0.0 or above. If you are not using Bandwidth's V2 Messaging, you do not need to update.

With go-bandwidth you have access to the entire set of API methods including:

  • Account - get user's account data and transactions,
  • Application - manage user's applications,
  • AvailableNumber - search free local or toll-free phone numbers,
  • Bridge - control bridges between calls,
  • Call - get access to user's calls,
  • Conference - manage user's conferences,
  • ConferenceMember - make actions with conference members,
  • Domain - get access to user's domains,
  • EntryPoint - control of endpoints of domains,
  • Error - list of errors,
  • Media - list, upload and download files to Bandwidth API server,
  • Message - send SMS/MMS, list messages,
  • NumberInfo - receive CNUM info by phone number,
  • PhoneNumber - get access to user's phone numbers,
  • Recording - mamange user's recordings.

Also you can work with Bandwidth XML using special types.

Install

     go get github.com/Bandwidth/go-bandwidth

Getting Started

  • Install go-bandwidth,
  • Get user id, api token and secret - You can get them here on the tab "Account",
  • Set user id, api token and secret
	import "github.com/Bandwidth/go-bandwidth"

	api := bandwidth.New("userId", "apiToken", "apiSecret")

Read Documentation for more details

Examples

All examples assume you have already setup your auth data!

List all calls from special number

  list, _ := api.GetCalls(&bandwidth.GetCallsQuery{From: "+19195551212"})

List all received messages

  list, _ := api.GetMessages(&bandwidth.GetMessagesQuery{State: "received"})

Send SMS

  messageId, _ := api.CreateMessage(&bandwidth.CreateMessageData{From: "+19195551212", To: "+191955512142", Text:"Test"})

Send SMS (via Messaging API v2)

  message, _ := api.CreateMessageV2(&CreateMessageDataV2{From: "fromNumber", To: "toNumber", Text: "text", ApplicationID: "YOUR_APPLICATION_ID"})

Send some SMSes

  statuses, error := api.CreateMessages(
	  &bandwidth.CreateMessageData{From: "+19195551212", To: "+191955512141", Text:"Test1"},
	  &bandwidth.CreateMessageData{From: "+19195551212", To: "+191955512142", Text:"Test2"})

Upload file

  api.UploadMediaFile("avatar.png", "/local/path/to/file.png", "image/png")

Make a call

  api.CreateCall(&bandwidth.CreateCallData{From: "+19195551212",  To: "+191955512142"})

Reject incoming call

  api.RejectIncomingCall(callId)

Create a gather

  api.CreateGather(callId, &bandwidth.CreateGatherData{MaxDigits: 3, InterDigitTimeout: 5, Prompt: &bandwidth.GatherPromptData{Sentence: "Please enter 3 digits"}})

Start a conference

  api.CreateConference(&bandwidth.CreateConferenceData{From: "+19195551212"})

Add a member to the conference

  api.CreateConferenceMember(conferenceId, &bandwidth.CreateConferenceMemberData{CallId: "id_of_call_to_add_to_this_conference", JoinTone: true, LeavingTone: true})

Connect 2 calls to a bridge

  api.CreateBridge(&bandwidth.BridgeData{CallIDs: []string{callId1, callId2}})

Search available local numbers to buy

  list, _ := api.GetAvailableNumbers(bandwidth.AvailableNumberTypeLocal, &bandwidth.GetAvailableNumberQuery{City: "Cary", State: "NC", Quantity: 3})

Get CNAM info for a number

  info, _ := api.GetNumberInfo("+19195551212")

Buy a phone number

  api.CreatePhoneNumber(&bandwidth.CreatePhoneNumberData{Number: "+19195551212"})

List recordings

  list, _ := api.GetRecordings()

Generate Bandwidth XML

   import (
	   "github.com/Bandwidth/go-bandwidth/xml"
	   "fmt"
   )

   response := &xml.Response{}
   speakSentence := xml.SpeakSentence{Sentence: "Transferring your call, please wait.", Voice: "paul", Gender: "male", Locale: "en_US"}
   transfer := xml.Transfer{
        TransferTo: "+13032218749",
        TransferCallerId: "private",
        SpeakSentence: &SpeakSentence{
            Sentence: "Inner speak sentence.",
            Voice: "paul",
            Gender: "male",
            Locale: "en_US"}}
    hangup := xml.Hangup{}

    append(response.Verbs, speakSentence)
	append(response.Verbs, transfer)
	append(response.Verbs, hangup)


    //as alternative we can pass list of verbs as
    //response = &xml.Response{Verbs = []interface{}{speakSentence, transfer, hangup}}

    fmt.Println(response.ToXML())

See directory examples for more demos.

Bugs/Issues

Please open an issue in this repository and we'll handle it directly. If you have any questions please contact us at developerhelp@bandwidth.com.

Documentation

Index

Constants

View Source
const Version = "1.0.0"

Version of this library

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Balance     float64 `json:"balance"`
	AccountType string  `json:"accountType"`
}

Account struct

type AccountTransaction

type AccountTransaction struct {
	ID          string  `json:"id"`
	Type        string  `json:"type"`
	Time        string  `json:"time"`
	Amount      float64 `json:"amount,string"`
	Units       int     `json:"units"`
	ProductType string  `json:"productType"`
	Number      string  `json:"number"`
}

AccountTransaction struct

type Application

type Application struct {
	ID                                string `json:"id,omitempty"`
	Name                              string `json:"name,omitempty"`
	IncomingCallURL                   string `json:"incomingCallUrl,omitempty"`
	IncomingCallURLCallbackTimeout    int    `json:"incomingCallUrlCallbackTimeout,omitempty"`
	IncomingCallFallbackURL           string `json:"incomingCallFallbackUrl,omitempty"`
	IncomingMessageURL                string `json:"incomingMessageUrl,omitempty"`
	IncomingMessageURLCallbackTimeout int    `json:"incomingMessageUrlCallbackTimeout,omitempty"`
	IncomingMessageFallbackURL        string `json:"incomingMessageFallbackUrl,omitempty"`
	CallbackHTTPMethod                string `json:"callbackHttpMethod,omitempty"`
	AutoAnswer                        bool   `json:"autoAnswer,omitempty"`
}

Application struct

type ApplicationData

type ApplicationData struct {
	Name                              string `json:"name,omitempty"`
	IncomingCallURL                   string `json:"incomingCallUrl,omitempty"`
	IncomingCallURLCallbackTimeout    int    `json:"incomingCallUrlCallbackTimeout,omitempty"`
	IncomingCallFallbackURL           string `json:"incomingCallFallbackUrl,omitempty"`
	IncomingMessageURL                string `json:"incomingMessageUrl,omitempty"`
	IncomingMessageURLCallbackTimeout int    `json:"incomingMessageUrlCallbackTimeout,omitempty"`
	IncomingMessageFallbackURL        string `json:"incomingMessageFallbackUrl,omitempty"`
	CallbackHTTPMethod                string `json:"callbackHttpMethod,omitempty"`
	AutoAnswer                        bool   `json:"autoAnswer,omitempty"`
}

ApplicationData struct

type AvailableNumber

type AvailableNumber struct {
	Number         string  `json:"number"`
	NationalNumber string  `json:"nationalNumber"`
	City           string  `json:"city"`
	LATA           string  `json:"lata"`
	RateCenter     string  `json:"rateCenter"`
	State          string  `json:"state"`
	Price          float64 `json:"price,string"`
}

AvailableNumber struct

type AvailableNumberType

type AvailableNumberType string

AvailableNumberType is allowed number types

const (
	// AvailableNumberTypeLocal is local number
	AvailableNumberTypeLocal AvailableNumberType = "local"

	// AvailableNumberTypeTollFree is toll free number
	AvailableNumberTypeTollFree AvailableNumberType = "tollFree"
)

type Bridge

type Bridge struct {
	ID            string   `json:"id"`
	State         string   `json:"state"`
	BridgeAudio   bool     `json:"bridgeAudio"`
	CallIDs       []string `json:"callIds"`
	CreatedTime   string   `json:"createdTime"`
	ActivatedTime string   `json:"activatedTime"`
	CompletedTime string   `json:"completedTime"`
}

Bridge struct

type BridgeData

type BridgeData struct {
	BridgeAudio bool     `json:"bridgeAudio,omitempty"`
	CallIDs     []string `json:"callIds,omitempty"`
}

BridgeData struct

type Call

type Call struct {
	ID                   string            `json:"id"`
	ActiveTime           string            `json:"activeTime"`
	StartTime            string            `json:"startTime"`
	EndTime              string            `json:"endTime"`
	ChargeableDuration   int               `json:"chargeableDuration"`
	Direction            string            `json:"direction"`
	From                 string            `json:"from"`
	RecordingFileFormat  string            `json:"recordingFileFormat"`
	RecordingEnabled     bool              `json:"recordingEnabled"`
	RecordingMaxDuration int               `json:"recordingMaxDuration"`
	State                string            `json:"state"`
	To                   string            `json:"to"`
	TranscriptionEnabled bool              `json:"transcriptionEnabled"`
	SipHeaders           map[string]string `json:"sipHeaders"`
	ConferenceID         string            `json:"conferenceId"`
	BridgeID             string            `json:"bridgeId"`
	TransferCallerID     string            `json:"transferCallerId"`
	TransferTo           string            `json:"transferTo"`
	Tag                  string            `json:"tag"`
	CallbackURL          string            `json:"callbackUrl"`
	CallbackHTTPMethod   string            `json:"callbackHttpMethod"`
	FallbackURL          string            `json:"fallbackUrl"`
	CallbackTimeout      int               `json:"callbackTimeout"`
}

Call struct

type CallEvent

type CallEvent struct {
	ID   string `json:"id"`
	Time string `json:"time"`
	Name string `json:"name"`
}

CallEvent struct

type Client

type Client struct {
	UserID, APIToken, APISecret string
	APIEndPoint                 string
	HTTPClient                  *http.Client
}

Client is main API object

func New

func New(userID, apiToken, apiSecret string, other ...string) (*Client, error)

New creates new instances of api It returns Client instance. Use it to make API calls. example: api := bandwidth.New("userId", "apiToken", "apiSecret")

func (*Client) AnswerIncomingCall

func (api *Client) AnswerIncomingCall(id string) error

AnswerIncomingCall answers an incoming call It returns error object example: api.CalAnswerIncomingCall("callId")

func (*Client) CreateApplication

func (api *Client) CreateApplication(data *ApplicationData) (string, error)

CreateApplication creates an application that can handle calls and messages for one of your phone number. Many phone numbers can share an application. It returns ID of created application or error

func (*Client) CreateBridge

func (api *Client) CreateBridge(data *BridgeData) (string, error)

CreateBridge creates a bridge It returns ID of created bridge

func (*Client) CreateCall

func (api *Client) CreateCall(data *CreateCallData) (string, error)

CreateCall creates an outbound phone call It returns ID of created call

func (*Client) CreateConference

func (api *Client) CreateConference(data *CreateConferenceData) (string, error)

CreateConference creates a new conference It returns ID of creeated conference

func (*Client) CreateConferenceMember

func (api *Client) CreateConferenceMember(id string, data *CreateConferenceMemberData) (string, error)

CreateConferenceMember creates a new conference member It returns ID of created member

func (*Client) CreateDomain

func (api *Client) CreateDomain(data *CreateDomainData) (string, error)

CreateDomain creates a new domain It returns ID of created domain or error

func (*Client) CreateDomainEndpoint

func (api *Client) CreateDomainEndpoint(id string, data *DomainEndpointData) (string, error)

CreateDomainEndpoint creates a new endpoint for a domain It returns ID of created endpoint or error

func (*Client) CreateDomainEndpointToken

func (api *Client) CreateDomainEndpointToken(id, endpointID string) (*DomainEndpointToken, error)

CreateDomainEndpointToken creates a new auth token for a domain's enpoint It returns token or error

func (*Client) CreateGather

func (api *Client) CreateGather(id string, data *CreateGatherData) (string, error)

CreateGather gathers the DTMF digits pressed in a call It returns ID of created gather or error

func (*Client) CreateMessage

func (api *Client) CreateMessage(data *CreateMessageData) (string, error)

CreateMessage sends a message (SMS/MMS) It returns ID of created message or error

func (*Client) CreateMessageV2

func (api *Client) CreateMessageV2(data *CreateMessageDataV2, other ...string) (*CreateMessageResultV2, error)

CreateMessageV2 sends a message (SMS/MMS)

func (*Client) CreateMessages

func (api *Client) CreateMessages(data ...*CreateMessageData) ([]*CreateMessageResult, error)

CreateMessages sends some messages (SMS/MMS) It statuses of created messages or error

func (*Client) CreatePhoneNumber

func (api *Client) CreatePhoneNumber(data *CreatePhoneNumberData) (string, error)

CreatePhoneNumber creates a new phone number It returns ID of created phone number or error

func (*Client) CreateRecordingTranscription

func (api *Client) CreateRecordingTranscription(id string) (string, error)

CreateRecordingTranscription creates a new transcription for a recording It returns ID of created transcription or error

func (*Client) DeleteApplication

func (api *Client) DeleteApplication(id string) error

DeleteApplication permanently deletes an application It returns error object

func (*Client) DeleteConferenceMember

func (api *Client) DeleteConferenceMember(id string, memberID string) error

DeleteConferenceMember removes the member from the conference example: api.DeleteConferenceMember("conferenceId", "memberId")

func (*Client) DeleteDomain

func (api *Client) DeleteDomain(id string) error

DeleteDomain removes a domain It returns error object

func (*Client) DeleteDomainEndpoint

func (api *Client) DeleteDomainEndpoint(id string, endpointID string) error

DeleteDomainEndpoint removes a endpoint from domain It returns error object

func (*Client) DeleteMediaFile

func (api *Client) DeleteMediaFile(name string) error

DeleteMediaFile removes a media file It returns error object

func (*Client) DeletePhoneNumber

func (api *Client) DeletePhoneNumber(id string) error

DeletePhoneNumber removes a phone number It returns error object

func (*Client) DownloadMediaFile

func (api *Client) DownloadMediaFile(name string) (io.ReadCloser, string, error)

DownloadMediaFile download media ffile It returns error io.ReadCloser, cotent type of downloaded file or error example: stream, contentType, err := api.DownloadMediaFile("file.jpg")

func (*Client) GetAccount

func (api *Client) GetAccount() (*Account, error)

GetAccount returns account information (balance, etc) It returns Account instance or error

func (*Client) GetAccountTransactions

func (api *Client) GetAccountTransactions() ([]*AccountTransaction, error)

GetAccountTransactions returns transactions from the user's account It returns list of AccountTransaction instances or error

func (*Client) GetAndOrderAvailableNumbers

func (api *Client) GetAndOrderAvailableNumbers(numberType AvailableNumberType, query *GetAvailableNumberQuery) ([]*OrderedNumber, error)

GetAndOrderAvailableNumbers looks for available numbers and orders them

func (*Client) GetApplication

func (api *Client) GetApplication(id string) (*Application, error)

GetApplication returns an user's application It returns Application instance or error

func (*Client) GetApplications

func (api *Client) GetApplications(query ...*GetApplicationsQuery) ([]*Application, error)

GetApplications returns list of user's applications It returns list of Application instances or error

func (*Client) GetAvailableNumbers

func (api *Client) GetAvailableNumbers(numberType AvailableNumberType, query *GetAvailableNumberQuery) ([]*AvailableNumber, error)

GetAvailableNumbers looks for available numbers

func (*Client) GetBridge

func (api *Client) GetBridge(id string) (*Bridge, error)

GetBridge returns a bridge It returns Bridge instance fo found bridge or error

func (*Client) GetBridgeCalls

func (api *Client) GetBridgeCalls(id string) ([]*Call, error)

GetBridgeCalls returns bridge's calls It returns list of Call instances or error

func (*Client) GetBridges

func (api *Client) GetBridges(query ...*GetBridgesQuery) ([]*Bridge, error)

GetBridges returns list of previous bridges It returns list of Bridge instances or error

func (*Client) GetCall

func (api *Client) GetCall(id string) (*Call, error)

GetCall returns information about a call that was made or received It return Call instance for found call or error

func (*Client) GetCallEvent

func (api *Client) GetCallEvent(id string, eventID string) (*CallEvent, error)

GetCallEvent returns information about one call event It returns CallEvent instance for found event or error

func (*Client) GetCallEvents

func (api *Client) GetCallEvents(id string) ([]*CallEvent, error)

GetCallEvents returns the list of call events for a call It returns list of CallEvent instances or error

func (*Client) GetCallRecordings

func (api *Client) GetCallRecordings(id string) ([]*Recording, error)

GetCallRecordings returns all recordings related to the call It return list of Recording instances or error

func (*Client) GetCallTranscriptions

func (api *Client) GetCallTranscriptions(id string) ([]*Transcription, error)

GetCallTranscriptions returns all transcriptions related to the call It return list of Transcription instances or error

func (*Client) GetCalls

func (api *Client) GetCalls(query ...*GetCallsQuery) ([]*Call, error)

GetCalls returns list of previous calls that were made or received It returns list of Call instances or error

func (*Client) GetConference

func (api *Client) GetConference(id string) (*Conference, error)

GetConference returns information about a conference It return Conference instance for found conference or error

func (*Client) GetConferenceMember

func (api *Client) GetConferenceMember(id string, memberID string) (*ConferenceMember, error)

GetConferenceMember returns information about one conference member It returns ConferenceMember instance for found instance or error

func (*Client) GetConferenceMembers

func (api *Client) GetConferenceMembers(id string) ([]*ConferenceMember, error)

GetConferenceMembers returns the list of conference members It returns list of ConferenceMember or error

func (*Client) GetDomainEndpoint

func (api *Client) GetDomainEndpoint(id string, endpointID string) (*DomainEndpoint, error)

GetDomainEndpoint returns single enpoint for a domain It returns DomainEndpoint instance or error

func (*Client) GetDomainEndpoints

func (api *Client) GetDomainEndpoints(id string, query ...*GetDomainEndpointsQuery) ([]*DomainEndpoint, error)

GetDomainEndpoints returns list of all endpoints for a domain It returns list of DomainEndpoint instances or error

func (*Client) GetDomains

func (api *Client) GetDomains(query ...*GetDomainsQuery) ([]*Domain, error)

GetDomains returns a list of the domains that have been created It returns list of Domain instances or error

func (*Client) GetError

func (api *Client) GetError(id string) (*Error, error)

GetError returns error by id It return Error instance for found error or error object

func (*Client) GetErrors

func (api *Client) GetErrors(query ...*GetErrorsQuery) ([]*Error, error)

GetErrors returns list of errors It returns list of Error instances or error

func (*Client) GetGather

func (api *Client) GetGather(id string, gatherID string) (*Gather, error)

GetGather returns the gather DTMF parameters and results of the call It returns Gather instance or error

func (*Client) GetMediaFiles

func (api *Client) GetMediaFiles() ([]*MediaFile, error)

GetMediaFiles returns a list of your media files It returns list of MediaFile instances or error

func (*Client) GetMessage

func (api *Client) GetMessage(id string) (*Message, error)

GetMessage returns a single message It returns Message instance or error

func (*Client) GetMessages

func (api *Client) GetMessages(query ...*GetMessagesQuery) ([]*Message, error)

GetMessages returns list of all messages It returns list of Message instances or error

func (*Client) GetNumberInfo

func (api *Client) GetNumberInfo(number string) (*NumberInfo, error)

GetNumberInfo returns information fo given number It returns NumberInfo instance or error

func (*Client) GetPhoneNumber

func (api *Client) GetPhoneNumber(idOrNumber string) (*PhoneNumber, error)

GetPhoneNumber returns information for phone number by id or number It returns instance of PhoneNumber or error

func (*Client) GetPhoneNumbers

func (api *Client) GetPhoneNumbers(query ...*GetPhoneNumbersQuery) ([]*PhoneNumber, error)

GetPhoneNumbers returns a list of your numbers It returns list of PhoneNumber instances or error

func (*Client) GetRecording

func (api *Client) GetRecording(id string) (*Recording, error)

GetRecording returns a single call recording It a Recording instance or error

func (*Client) GetRecordingTranscription

func (api *Client) GetRecordingTranscription(recordingID string, transcriptionID string) (*Transcription, error)

GetRecordingTranscription returns single enpoint for a recording It returns Transcription instance or error

func (*Client) GetRecordingTranscriptions

func (api *Client) GetRecordingTranscriptions(id string) ([]*Transcription, error)

GetRecordingTranscriptions returns list of all transcriptions for a recording It returns list of Transcription instances or error

func (*Client) GetRecordings

func (api *Client) GetRecordings(query ...*GetRecordingsQuery) ([]*Recording, error)

GetRecordings returns a list of the calls recordings It returns list of Recording instances or error

func (*Client) HangUpCall

func (api *Client) HangUpCall(id string) error

HangUpCall hangs up the call It returns error object example: api.HangUpCall("callId")

func (*Client) HoldConferenceMember

func (api *Client) HoldConferenceMember(id string, memberID string, hold bool) error

HoldConferenceMember hold/unhold the conference member example: api.HoldConferenceMember("conferenceId", "memberId", true) //hold member

func (*Client) MuteConference

func (api *Client) MuteConference(id string, mute bool) error

MuteConference mutes/unmutes a conference example: api.MuteConference("conferenceId", false) //unmute it

func (*Client) MuteConferenceMember

func (api *Client) MuteConferenceMember(id string, memberID string, mute bool) error

MuteConferenceMember mute/unmute the conference member example: api.MuteConferenceMember("conferenceId", "memberId", true) //mute member

func (*Client) PlayAudioToBridge

func (api *Client) PlayAudioToBridge(id string, data *PlayAudioData) error

PlayAudioToBridge plays an audio or speak a sentence in a bridge It returns error object

func (*Client) PlayAudioToCall

func (api *Client) PlayAudioToCall(id string, data *PlayAudioData) error

PlayAudioToCall plays an audio or speak a sentence in a call It returns error object

func (*Client) PlayAudioToCallWithMap

func (api *Client) PlayAudioToCallWithMap(id string, data map[string]interface{}) error

PlayAudioToCallWithMap plays an audio or speak a sentence in a call It returns error object

func (*Client) PlayAudioToConference

func (api *Client) PlayAudioToConference(id string, data *PlayAudioData) error

PlayAudioToConference plays an audio or speak a sentence in a conference It returns error object

func (*Client) PlayAudioToConferenceMember

func (api *Client) PlayAudioToConferenceMember(id string, memberID string, data *PlayAudioData) error

PlayAudioToConferenceMember plays an audio or speak a sentence to a conference member It returns error object

func (*Client) RejectIncomingCall

func (api *Client) RejectIncomingCall(id string) error

RejectIncomingCall answers an incoming call It returns error object example: api.RejectIncomingCall("callId")

func (*Client) SendDTMFCharactersToCall

func (api *Client) SendDTMFCharactersToCall(id string, dtmfOut string) error

SendDTMFCharactersToCall sends some dtmf characters to call It returns error object example: api.SendDTMFCharactersToCall("callId", "1")

func (*Client) SendDTMFToCall

func (api *Client) SendDTMFToCall(id string, data *SendDTMFToCallData) error

SendDTMFToCall plays an audio or speak a sentence in a call It returns error object

func (*Client) SetCallRecodingEnabled

func (api *Client) SetCallRecodingEnabled(id string, enabled bool) error

SetCallRecodingEnabled hangs up the call It returns error object example: api.SetCallRecodingEnabled("callId", true) // enable recording

func (*Client) StopGather

func (api *Client) StopGather(id string, gatherID string) error

StopGather stops call's gather It returns error object example: api.StopGather("callId")

func (*Client) TerminateConference

func (api *Client) TerminateConference(id string) error

TerminateConference terminates a conference example: api.TerminateConference("conferenceId")

func (*Client) UpdateApplication

func (api *Client) UpdateApplication(id string, changedData *ApplicationData) error

UpdateApplication makes changes to an application It returns error object

func (*Client) UpdateBridge

func (api *Client) UpdateBridge(id string, changedData *BridgeData) error

UpdateBridge adds one or two calls in a bridge and also puts the bridge on hold/unhold It returns error object

func (*Client) UpdateCall

func (api *Client) UpdateCall(id string, changedData *UpdateCallData) (string, error)

UpdateCall manage an active phone call. E.g. Answer an incoming call, reject an incoming call, turn on / off recording, transfer, hang up It returns error object

func (*Client) UpdateConference

func (api *Client) UpdateConference(id string, data *UpdateConferenceData) error

UpdateConference manage an active phone conference. E.g. Answer an incoming conference, reject an incoming conference, turn on / off recording, transfer, hang up It returns error object

func (*Client) UpdateConferenceMember

func (api *Client) UpdateConferenceMember(id string, memberID string, data *UpdateConferenceMemberData) error

UpdateConferenceMember updates a conference member It returns error object

func (*Client) UpdateDomainEndpoint

func (api *Client) UpdateDomainEndpoint(id string, endpointID string, changedData *DomainEndpointData) error

UpdateDomainEndpoint removes a endpoint from domain It returns error object

func (*Client) UpdateGather

func (api *Client) UpdateGather(id string, gatherID string, data *UpdateGatherData) error

UpdateGather updates call's gather data It returns error object

func (*Client) UpdatePhoneNumber

func (api *Client) UpdatePhoneNumber(idOrNumber string, data *UpdatePhoneNumberData) error

UpdatePhoneNumber makes changes to your number It returns error object

func (*Client) UploadMediaFile

func (api *Client) UploadMediaFile(name string, file interface{}, contentType ...string) error

UploadMediaFile creates a new media from file or any io.ReadCloser instance It returns error object example: api.UploadMediaFile("file.jpg", "/path/ti/file.jpg", "image/jpeg") api.UploadMediaFile("file.bin", readCloserInstance) // using io.ReadCloser instance

type Conference

type Conference struct {
	ID                 string `json:"id"`
	State              string `json:"state"`
	From               string `json:"from"`
	CreatedTime        string `json:"createdTime"`
	CompletedTime      string `json:"completedTime"`
	ActiveMembers      int    `json:"activeMembers"`
	CallbackURL        string `json:"callbackUrl"`
	CallbackTimeout    int    `json:"callbackTimeout"`
	CallbackHTTPMethod string `json:"callbackHttpMethod"`
	FallbackURL        string `json:"fallbackUrl"`
	Hold               bool   `json:"hold"`
	Mute               bool   `json:"mute"`
	Tag                string `json:"tag"`
	Profile            string `json:"profile"`
}

Conference struct

type ConferenceMember

type ConferenceMember struct {
	ID          string `json:"id"`
	Call        string `json:"call"`
	State       string `json:"state"`
	AddedTime   string `json:"addedTime"`
	RemovedTime string `json:"removedTime"`
	Hold        bool   `json:"hold"`
	Mute        bool   `json:"mute"`
	JoinTone    bool   `json:"joinTone"`
	LeavingTone bool   `json:"leavingTone"`
}

ConferenceMember struct

func (*ConferenceMember) GetCallID

func (m *ConferenceMember) GetCallID() string

GetCallID returns call ID of member

type CreateCallData

type CreateCallData struct {
	From                 string            `json:"from,omitempty"`
	RecordingFileFormat  string            `json:"recordingFileFormat,omitempty"`
	RecordingEnabled     bool              `json:"recordingEnabled,omitempty"`
	RecordingMaxDuration int               `json:"recordingMaxDuration,omitempty"`
	State                string            `json:"state,omitempty"`
	To                   string            `json:"to,omitempty"`
	TranscriptionEnabled bool              `json:"transcriptionEnabled,omitempty"`
	SipHeaders           map[string]string `json:"sipHeaders,omitempty"`
	ConferenceID         string            `json:"conferenceId,omitempty"`
	BridgeID             string            `json:"bridgeId,omitempty"`
	Tag                  string            `json:"tag,omitempty"`
	CallbackURL          string            `json:"callbackUrl,omitempty"`
	CallbackHTTPMethod   string            `json:"callbackHttpMethod,omitempty"`
	FallbackURL          string            `json:"fallbackUrl,omitempty"`
	CallbackTimeout      int               `json:"callbackTimeout,omitempty"`
	CallTimeout          int               `json:"callTimeout,omitempty"`
}

CreateCallData struct

type CreateConferenceData

type CreateConferenceData struct {
	From               string `json:"from,omitempty"`
	CallbackURL        string `json:"callbackUrl,omitempty"`
	CallbackTimeout    int    `json:"callbackTimeout,omitempty"`
	FallbackURL        string `json:"fallbackUrl,omitempty"`
	Tag                string `json:"tag,omitempty"`
	Profile            string `json:"profile,omitempty"`
	CallbackHTTPMethod string `json:"callbackHttpMethod,omitempty"`
}

CreateConferenceData struct

type CreateConferenceMemberData

type CreateConferenceMemberData struct {
	CallID      string `json:"callId"`
	Hold        bool   `json:"hold,omitempty"`
	Mute        bool   `json:"mute,omitempty"`
	JoinTone    bool   `json:"joinTone,omitempty"`
	LeavingTone bool   `json:"leavingTone,omitempty"`
}

CreateConferenceMemberData struct

type CreateDomainData

type CreateDomainData struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
}

CreateDomainData struct

type CreateGatherData

type CreateGatherData struct {
	MaxDigits         int               `json:"maxDigits,string,omitempty"`
	InterDigitTimeout int               `json:"interDigitTimeout,string,omitempty"`
	TerminatingDigits string            `json:"terminatingDigits,omitempty"`
	Tag               string            `json:"tag,omitempty"`
	Prompt            *GatherPromptData `json:"prompt,omitempty"`
}

CreateGatherData struct

type CreateMessageData

type CreateMessageData struct {
	From               string   `json:"from,omitempty"`
	To                 string   `json:"to,omitempty"`
	Text               string   `json:"text,omitempty"`
	Media              []string `json:"media,omitempty"`
	CallbackURL        string   `json:"callbackUrl,omitempty"`
	CallbackHTTPMethod string   `json:"callbackHttpMethod,omitempty"`
	FallbackURL        string   `json:"fallbackUrl,omitempty"`
	CallbackTimeout    int      `json:"callbackTimeout,omitempty"`
	ReceiptRequested   string   `json:"receiptRequested,omitempty"`
	Tag                string   `json:"tag,omitempty"`
}

CreateMessageData struct

type CreateMessageDataV2

type CreateMessageDataV2 struct {
	From          string      `json:"from,omitempty"`
	To            interface{} `json:"to,omitempty"`
	Text          string      `json:"text,omitempty"`
	Media         []string    `json:"media,omitempty"`
	ApplicationID string      `json:"applicationId,omitempty"`
	Tag           string      `json:"tag,omitempty"`
}

CreateMessageDataV2 struct

type CreateMessageResult

type CreateMessageResult struct {
	Result   string `json:"result,omitempty"`
	Location string `json:"location,omitempty"`
	ID       string `json:"-"`
}

CreateMessageResult stores status of sent message (in batch mode)

type CreateMessageResultV2

type CreateMessageResultV2 struct {
	ID            string      `json:"id"`
	Time          *time.Time  `json:"time,string"`
	From          string      `json:"from"`
	To            interface{} `json:"to"`
	Text          string      `json:"text"`
	Media         []string    `json:"media"`
	ApplicationID string      `json:"applicationId"`
	Tag           string      `json:"tag"`
	Direction     string      `json:"direction"`
	SegmentCount  int32       `json:"segmentCount"`
}

CreateMessageResultV2 stores status of sent message

type CreatePhoneNumberData

type CreatePhoneNumberData struct {
	Number         string               `json:"number,omitempty"`
	Name           string               `json:"name,omitempty"`
	ApplicationID  string               `json:"applicationId,omitempty"`
	FallbackNumber string               `json:"fallbackNumber,omitempty"`
	Provider       *PhoneNumberProvider `json:"provider,omitempty"`
}

CreatePhoneNumberData struct

type Domain

type Domain struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Domain struct

type DomainEndpoint

type DomainEndpoint struct {
	ID            string                     `json:"id"`
	Name          string                     `json:"name"`
	Description   string                     `json:"description"`
	DomainID      string                     `json:"domainId"`
	ApplicationID string                     `json:"applicationId"`
	Enabled       bool                       `json:"enabled"`
	SipURI        string                     `json:"sipUri"`
	Credentials   *DomainEndpointCredentials `json:"credentials"`
}

DomainEndpoint struct

type DomainEndpointCredentials

type DomainEndpointCredentials struct {
	Password string `json:"password,omitempty"`
	UserName string `json:"username,omitempty"`
	Realm    string `json:"realm,omitempty"`
}

DomainEndpointCredentials struct

type DomainEndpointData

type DomainEndpointData struct {
	Name          string                     `json:"name,omitempty"`
	Description   string                     `json:"description,omitempty"`
	DomainID      string                     `json:"domainId,omitempty"`
	ApplicationID string                     `json:"applicationId,omitempty"`
	Enabled       bool                       `json:"enabled"`
	SipURI        string                     `json:"sipUri,omitempty"`
	Credentials   *DomainEndpointCredentials `json:"credentials,omitempty"`
}

DomainEndpointData struct

type DomainEndpointToken

type DomainEndpointToken struct {
	Token   string `json:"token"`
	Expires int    `json:"expires"`
}

DomainEndpointToken struct

type Error

type Error struct {
	ID       string         `json:"id"`
	Category string         `json:"category"`
	Time     string         `json:"time"`
	Code     string         `json:"code"`
	Message  string         `json:"message"`
	Details  []*ErrorDetail `json:"details"`
}

Error struct

type ErrorDetail

type ErrorDetail struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

ErrorDetail struct

type Gather

type Gather struct {
	ID            string `json:"id"`
	State         string `json:"state"`
	Reason        string `json:"reason"`
	CreatedTime   string `json:"createdTime"`
	CompletedTime string `json:"completedTime"`
	Digits        string `json:"digits"`
}

Gather struct

type GatherPromptData

type GatherPromptData struct {
	FileURL     string `json:"fileUrl,omitempty"`
	Sentence    string `json:"sentence,omitempty"`
	Gender      string `json:"gender,omitempty"`
	Locale      string `json:"locale,omitempty"`
	Voice       string `json:"voice,omitempty"`
	LoopEnabled bool   `json:"loopEnabled,omitempty"`
	Bargeable   bool   `json:"bargeable, string"`
}

GatherPromptData struct

type GetApplicationsQuery

type GetApplicationsQuery struct {
	Page int
	Size int
}

GetApplicationsQuery is optional parameters of GetApplications()

type GetAvailableNumberQuery

type GetAvailableNumberQuery struct {
	City               string
	State              string
	Zip                string
	AreaCode           string
	LocalNumber        string
	InLocalCallingArea bool
	Quantity           int
	Pattern            string
}

GetAvailableNumberQuery is query parameters of GetAvailableNumbers() and GetAndOrderAvailableNumbers()

type GetBridgesQuery

type GetBridgesQuery struct {
	Page int
	Size int
}

GetBridgesQuery is optional parameters of GetBridges()

type GetCallsQuery

type GetCallsQuery struct {
	Page         int
	Size         int
	BridgeID     string
	ConferenceID string
	From         string
	To           string
	SortOrder    string
}

GetCallsQuery is optional parameters of GetCalls()

type GetDomainEndpointsQuery

type GetDomainEndpointsQuery struct {
	Page int
	Size int
}

GetDomainEndpointsQuery is optional parameters of GetDomainEndpoints()

type GetDomainsQuery

type GetDomainsQuery struct {
	Size int
}

GetDomainsQuery is optional parameters of GetDomains()

type GetErrorsQuery

type GetErrorsQuery struct {
	Page int
	Size int
}

GetErrorsQuery is optional parameters of GetErrors()

type GetMessagesQuery

type GetMessagesQuery struct {
	Page          int
	Size          int
	From          string
	To            string
	FromDateTime  string
	ToDateTime    string
	Direction     string
	State         string
	DeliveryState string
	SortOrder     string
}

GetMessagesQuery is optional parameters of GetMessages()

type GetPhoneNumbersQuery

type GetPhoneNumbersQuery struct {
	Page          int
	Size          int
	ApplicationID string
	State         string
	Name          string
	City          string
	NumberState   string
}

GetPhoneNumbersQuery is optional parameters of GetPhoneNumbers()

type GetRecordingsQuery

type GetRecordingsQuery struct {
	Page int
	Size int
}

GetRecordingsQuery is optional parameters of GetRecordings()

type MediaFile

type MediaFile struct {
	ContentLength int64  `json:"contentLength"`
	Content       string `json:"content"`
	MediaName     string `json:"mediaName"`
}

MediaFile struct

type Message

type Message struct {
	ID                  string   `json:"id"`
	From                string   `json:"from"`
	To                  string   `json:"to"`
	Direction           string   `json:"direction"`
	Text                string   `json:"text"`
	Media               []string `json:"media"`
	State               string   `json:"state"`
	Time                string   `json:"time"`
	CallbackURL         string   `json:"callbackUrl"`
	CallbackHTTPMethod  string   `json:"callbackHttpMethod,omitempty"`
	FallbackURL         string   `json:"fallbackUrl,omitempty"`
	CallbackTimeout     int      `json:"callbackTimeout,omitempty"`
	ReceiptRequested    string   `json:"receiptRequested"`
	DeliveryState       string   `json:"deliveryState"`
	DeliveryCode        string   `json:"deliveryCode"`
	DeliveryDescription string   `json:"deliveryDescription"`
	Tag                 string   `json:"tag"`
}

Message struct

type NumberInfo

type NumberInfo struct {
	Number  string `json:"number"`
	Name    string `json:"name"`
	Created string `json:"created"`
	Updated string `json:"updated"`
}

NumberInfo struct

type OrderedNumber

type OrderedNumber struct {
	Number         string  `json:"number"`
	NationalNumber string  `json:"nationalNumber"`
	Price          float64 `json:"price,string"`
	Location       string  `json:"Location"`
	ID             string  `json:"-"`
}

OrderedNumber struct

type PhoneNumber

type PhoneNumber struct {
	ID             string  `json:"id"`
	Name           string  `json:"name"`
	Number         string  `json:"number"`
	NationalNumber string  `json:"nationalNumber"`
	City           string  `json:"city"`
	State          string  `json:"state"`
	ApplicationID  string  `json:"applicationId"`
	FallbackNumber string  `json:"fallbackNumber"`
	CreatedTime    string  `json:"createdTime"`
	NumberState    string  `json:"numberState"`
	Price          float64 `json:"price,string"`
}

PhoneNumber struct

type PhoneNumberProvider

type PhoneNumberProvider struct {
	Name       string                 `json:"providerName,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
}

PhoneNumberProvider struct

type PlayAudioData

type PlayAudioData struct {
	FileURL     string `json:"fileUrl,omitempty"`
	Sentence    string `json:"sentence,omitempty"`
	Gender      string `json:"gender,omitempty"`
	Locale      string `json:"locale,omitempty"`
	Voice       string `json:"voice,omitempty"`
	LoopEnabled bool   `json:"loopEnabled,omitempty"`
	Tag         string `json:"tag,omitempty"`
}

PlayAudioData struct

type RateLimitError

type RateLimitError struct {
	Reset time.Time
}

RateLimitError is error for 429 http error

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type Recording

type Recording struct {
	ID        string `json:"id"`
	EndTime   string `json:"endTime"`
	Media     string `json:"media"`
	Call      string `json:"call"`
	StartTime string `json:"startTime"`
	State     string `json:"state"`
}

Recording struct

type SendDTMFToCallData

type SendDTMFToCallData struct {
	DTMFOut string `json:"dtmfOut,omitempty"`
}

SendDTMFToCallData struct

type Transcription

type Transcription struct {
	ID                 string `json:"id"`
	ChargeableDuration int    `json:"chargeableDuration"`
	Text               string `json:"text"`
	TextSize           int    `json:"textSize"`
	TextURL            string `json:"textUrl"`
	Time               string `json:"time"`
}

Transcription struct

type UpdateCallData

type UpdateCallData struct {
	TransferCallerID     string         `json:"transferCallerId,omitempty"`
	TransferTo           string         `json:"transferTo,omitempty"`
	RecordingEnabled     bool           `json:"recordingEnabled,string,omitempty"`
	RecordingFileFormat  string         `json:"recordingFileFormat,omitempty"`
	State                string         `json:"state,omitempty"`
	TranscriptionEnabled bool           `json:"transcriptionEnabled,string,omitempty"`
	CallbackURL          string         `json:"callbackUrl,omitempty"`
	WhisperAudio         *PlayAudioData `json:"whisperAudio,omitempty"`
	Tag                  string         `json:"tag,omitempty"`
}

UpdateCallData struct

type UpdateConferenceData

type UpdateConferenceData struct {
	State              string `json:"state,omitempty"`
	CallbackURL        string `json:"callbackUrl,omitempty"`
	CallbackTimeout    int    `json:"callbackTimeout,string,omitempty"`
	FallbackURL        string `json:"fallbackUrl,omitempty"`
	Hold               bool   `json:"hold,omitempty"`
	Mute               bool   `json:"mute,omitempty"`
	Tag                string `json:"tag,omitempty"`
	CallbackHTTPMethod string `json:"callbackHttpMethod,omitempty"`
}

UpdateConferenceData struct

type UpdateConferenceMemberData

type UpdateConferenceMemberData struct {
	State       string `json:"state,omitempty"`
	Hold        bool   `json:"hold,omitempty"`
	Mute        bool   `json:"mute,omitempty"`
	JoinTone    bool   `json:"joinTone,omitempty"`
	LeavingTone bool   `json:"leavingTone,omitempty"`
}

UpdateConferenceMemberData struct

type UpdateGatherData

type UpdateGatherData struct {
	State string `json:"state,omitempty"`
}

UpdateGatherData struct

type UpdatePhoneNumberData

type UpdatePhoneNumberData struct {
	Name           string `json:"name,omitempty"`
	ApplicationID  string `json:"applicationId,omitempty"`
	FallbackNumber string `json:"fallbackNumber,omitempty"`
}

UpdatePhoneNumberData struct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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