Documentation ¶
Overview ¶
Package goexoml The ExoML library for golang goexoml is the official ExoML library written in golang. ExoML(ExotelMarkupLanguage) enables one to add logic to calls.
When someone makes a call to an *exophone* ,Exotel will look up the URL associated with *exophone* and make a request to that URL.
sample Code
package main import ( "fmt" "github.com/exotel/goexoml" ) //Example - creates a sample response as follows // <?xml version="1.0" encoding="UTF-8"?> // <Response> // <Say> // Please leave a message at the beep. // Press the star key when finished. // </Say> // <Record // action="http://example.exotel.in/handleRecording" // method="GET" // maxLength="20" // finishOnKey="*" // /> // <Say>I did not receive a recording</Say> // </Response> func Example() (string, error) { //create a new response object resp := goexoml.NewResponse() //create a new say verb and add attributes and values say1 := goexoml.NewSay().SetText("Please leave a message at the beep.\n Press the star key when finished.") //create a new say verb and add attributes and values say2 := goexoml.NewSay().SetText("I did not receive a recording.") //create the recors vberb and add attributes rec := goexoml.NewRecord().SetAction("http://example.exotel.in/handleRecording").SetMethod("GET").SetMaxLength(20) //Add the Action verbs to the response object in expected order err := resp.Action(say1, rec, say2) if err != nil { fmt.Println(err.Error()) return "", err } // OR ////Add the Action verbs to the response object in expected order // resp.AddSay(say1).AddRecord(rec).AddSay(say2) return resp.String(), nil } func main() { exoml, err := Example() if err != nil { fmt.Print("Error occured :", err.Error()) return } fmt.Println(exoml) return }
Index ¶
- Variables
- type Dial
- func (__dial__ *Dial) SetAction(action string) *Dial
- func (__dial__ *Dial) SetCallerID(callerid string) *Dial
- func (__dial__ *Dial) SetHangupOnStar(hanguponstar bool) *Dial
- func (__dial__ *Dial) SetMethod(method string) *Dial
- func (__dial__ *Dial) SetNumber(number *Number) *Dial
- func (__dial__ *Dial) SetPlainNumber(plainnumber string) *Dial
- func (__dial__ *Dial) SetRecord(record bool) *Dial
- func (__dial__ *Dial) SetTimeLimit(timelimit int) *Dial
- func (__dial__ *Dial) SetTimeout(timeout int) *Dial
- type Gather
- func (__gather__ *Gather) SetAction(action string) *Gather
- func (__gather__ *Gather) SetFinishOnKey(finishonkey string) *Gather
- func (__gather__ *Gather) SetMethod(method string) *Gather
- func (__gather__ *Gather) SetNumDigits(numdigits int) *Gather
- func (__gather__ *Gather) SetPlay(play *Play) *Gather
- func (__gather__ *Gather) SetSay(say *Say) *Gather
- func (__gather__ *Gather) SetTimeout(timeout int) *Gather
- type Hangup
- type IDial
- type IGather
- type IHangup
- type INumber
- type IPlay
- type IRecord
- type IRedirect
- type ISay
- type Number
- func (__number__ *Number) SetMethod(method string) *Number
- func (__number__ *Number) SetNoun(noun string) *Number
- func (__number__ *Number) SetSendDigits(senddigits string) *Number
- func (__number__ *Number) SetStatusCallback(statuscallback string) *Number
- func (__number__ *Number) SetStatusCallbackEvent(statuscallbackevent string) *Number
- func (__number__ *Number) SetStatusCallbackMethod(statuscallbackmethod string) *Number
- func (__number__ *Number) SetURL(url string) *Number
- type Play
- type Record
- func (__record__ *Record) SetAction(action string) *Record
- func (__record__ *Record) SetFinishOnKey(finishonkey string) *Record
- func (__record__ *Record) SetMaxLength(maxlength int) *Record
- func (__record__ *Record) SetMethod(method string) *Record
- func (__record__ *Record) SetPlayBeep(playbeep bool) *Record
- func (__record__ *Record) SetTimeout(timeout int) *Record
- func (__record__ *Record) SetTranscribe(transcribe bool) *Record
- func (__record__ *Record) SetTranscribeCallback(transcribecallback string) *Record
- func (__record__ *Record) SetTrim(trim string) *Record
- type Redirect
- type Response
- func (r *Response) Action(verbs ...interface{}) error
- func (r *Response) AddDial(dial IDial) *Response
- func (r *Response) AddGather(gather IGather) *Response
- func (r *Response) AddHangup(hangup IHangup) *Response
- func (r *Response) AddNumber(number INumber) *Response
- func (r *Response) AddPlay(play IPlay) *Response
- func (r *Response) AddRecord(record IRecord) *Response
- func (r *Response) AddRedirect(redirect IRedirect) *Response
- func (r *Response) AddSay(say ISay) *Response
- func (r Response) String() string
- type Say
Constants ¶
This section is empty.
Variables ¶
var CallStatus = struct { EXOQueued string EXORinging string EXOInProgress string EXOCompleted string EXOBusy string EXOFailed string EXONoAnswer string EXOCanceled string }{ EXOQueued: "queued", EXORinging: "ringing", EXOInProgress: "in-progress", EXOCompleted: "completed", EXOBusy: "busy", EXOFailed: "failed", EXONoAnswer: "no-answer", EXOCanceled: "canceled", }
Constants for CallStatus
Functions ¶
This section is empty.
Types ¶
type Dial ¶
type Dial struct { XMLName xml.Name `xml:"Dial"` Action string `xml:"action,attr,omitempty"` Method string `xml:"method,attr,omitempty"` Timeout int `xml:"timeout,attr,omitempty"` HangupOnStar bool `xml:"hangupOnStar,attr,omitempty"` TimeLimit int `xml:"timeLimit,attr,omitempty"` CallerID string `xml:"callerId,attr,omitempty"` Record bool `xml:"record,attr,omitempty"` PlainNumber string `xml:",innerxml"` Number *Number `xml:",innerxml"` }
Dial struct for the verb Dial which allows a number as plain test
func (*Dial) SetCallerID ¶
SetCallerID sets CallerID for Dial struct instance
func (*Dial) SetHangupOnStar ¶
SetHangupOnStar sets HangupOnStar for Dial struct instance
func (*Dial) SetPlainNumber ¶
SetPlainNumber sets PlainNumber for Dial struct instance
func (*Dial) SetTimeLimit ¶
SetTimeLimit sets TimeLimit for Dial struct instance
func (*Dial) SetTimeout ¶
SetTimeout sets Timeout for Dial struct instance
type Gather ¶
type Gather struct { XMLName xml.Name `xml:"Gather"` Action string `xml:"action,attr,omitempty"` Method string `xml:"method,attr,omitempty"` Timeout int `xml:"timeout,attr,omitempty"` FinishOnKey string `xml:"finishOnKey,attr,omitempty"` NumDigits int `xml:"numDigits,attr,omitempty"` Say *Say `xml:",innerxml"` Play *Play `xml:",innerxml"` }
Gather struct for the verb Gather
func (*Gather) SetFinishOnKey ¶
SetFinishOnKey sets FinishOnKey for Gather struct instance
func (*Gather) SetNumDigits ¶
SetNumDigits sets NumDigits for Gather struct instance
func (*Gather) SetTimeout ¶
SetTimeout sets Timeout for Gather struct instance
type IDial ¶
type IDial interface { SetAction(action string) *Dial SetMethod(method string) *Dial SetTimeout(timeout int) *Dial SetHangupOnStar(hanguponstar bool) *Dial SetTimeLimit(timelimit int) *Dial SetCallerID(callerid string) *Dial SetRecord(record bool) *Dial SetPlainNumber(plainnumber string) *Dial SetNumber(number *Number) *Dial }
IDial The interface that satisfies all the methods for this struct IDial asserts implementation of setters for all the fields of Dial
type IGather ¶
type IGather interface { SetAction(action string) *Gather SetMethod(method string) *Gather SetTimeout(timeout int) *Gather SetFinishOnKey(finishonkey string) *Gather SetNumDigits(numdigits int) *Gather SetSay(say *Say) *Gather SetPlay(play *Play) *Gather }
IGather The interface that satisfies all the methods for this struct IGather asserts implementation of setters for all the fields of Gather
type IHangup ¶
type IHangup interface { }
IHangup The interface that satisfies all the methods for this struct IHangup asserts implementation of setters for all the fields of Hangup
type INumber ¶
type INumber interface { SetSendDigits(senddigits string) *Number SetURL(url string) *Number SetMethod(method string) *Number SetStatusCallbackEvent(statuscallbackevent string) *Number SetStatusCallback(statuscallback string) *Number SetStatusCallbackMethod(statuscallbackmethod string) *Number SetNoun(noun string) *Number }
INumber The interface that satisfies all the methods for this struct INumber asserts implementation of setters for all the fields of Number
type IPlay ¶
type IPlay interface { SetLoop(loop int) *Play SetDigits(digits int) *Play SetURL(url string) *Play }
IPlay The interface that satisfies all the methods for this struct IPlay asserts implementation of setters for all the fields of Play
type IRecord ¶
type IRecord interface { SetAction(action string) *Record SetMethod(method string) *Record SetTimeout(timeout int) *Record SetFinishOnKey(finishonkey string) *Record SetMaxLength(maxlength int) *Record SetTranscribe(transcribe bool) *Record SetTranscribeCallback(transcribecallback string) *Record SetPlayBeep(playbeep bool) *Record SetTrim(trim string) *Record }
IRecord The interface that satisfies all the methods for this struct IRecord asserts implementation of setters for all the fields of Record
type IRedirect ¶
IRedirect The interface that satisfies all the methods for this struct IRedirect asserts implementation of setters for all the fields of Redirect
type ISay ¶
type ISay interface { SetVoice(voice string) *Say SetLanguage(language string) *Say SetLoop(loop int) *Say SetText(text string) *Say }
ISay The interface that satisfies all the methods for this struct ISay asserts implementation of setters for all the fields of Say
type Number ¶
type Number struct { XMLName xml.Name `xml:"Number"` SendDigits string `xml:"sendDigits,attr,omitempty"` URL string `xml:"URL,attr,omitempty"` Method string `xml:"method,attr,omitempty"` StatusCallbackEvent string `xml:"statusCallbackEvent,attr,omitempty"` StatusCallback string `xml:"StatusCallback,attr,omitempty"` StatusCallbackMethod string `xml:"StatusCallbackMethod,attr,omitempty"` Noun string `xml:",innerxml"` }
Number struct for the noun Number
func (*Number) SetSendDigits ¶
SetSendDigits sets SendDigits for Number struct instance
func (*Number) SetStatusCallback ¶
SetStatusCallback sets StatusCallback for Number struct instance
func (*Number) SetStatusCallbackEvent ¶
SetStatusCallbackEvent sets StatusCallbackEvent for Number struct instance
func (*Number) SetStatusCallbackMethod ¶
SetStatusCallbackMethod sets StatusCallbackMethod for Number struct instance
type Play ¶
type Play struct { XMLName xml.Name `xml:"Play"` Loop int `xml:"loop,attr,omitempty"` Digits int `xml:"digits,attr,omitempty"` URL string `xml:",innerxml"` }
Play struct for the verb Play
type Record ¶
type Record struct { XMLName xml.Name `xml:"Record"` Action string `xml:"action,attr,omitempty"` Method string `xml:"method,attr,omitempty"` Timeout int `xml:"timeout,attr,omitempty"` FinishOnKey string `xml:"finishOnKey,attr,omitempty"` MaxLength int `xml:"maxLength,attr,omitempty"` Transcribe bool `xml:"transcribe,attr,omitempty"` TranscribeCallback string `xml:"transcribeCallback,attr,omitempty"` PlayBeep bool `xml:"playBeep,attr,omitempty"` Trim string `xml:"trim,attr,omitempty"` }
Record struct for the verb Record
func (*Record) SetFinishOnKey ¶
SetFinishOnKey sets FinishOnKey for Record struct instance
func (*Record) SetMaxLength ¶
SetMaxLength sets MaxLength for Record struct instance
func (*Record) SetPlayBeep ¶
SetPlayBeep sets PlayBeep for Record struct instance
func (*Record) SetTimeout ¶
SetTimeout sets Timeout for Record struct instance
func (*Record) SetTranscribe ¶
SetTranscribe sets Transcribe for Record struct instance
func (*Record) SetTranscribeCallback ¶
SetTranscribeCallback sets TranscribeCallback for Record struct instance
type Redirect ¶
type Redirect struct { XMLName xml.Name `xml:"Redirect"` Method string `xml:"method,attr,omitempty"` URL string `xml:",innerxml"` }
Redirect struct for the verb Redirect
type Response ¶
Response struct for the verb Response the wrapper struct that accomodates all the Verbs as a sequence of verbs
func NewResponse ¶
func NewResponse() *Response
NewResponse returns a pointer to the reposne structure
func (*Response) Action ¶
Action appends action verb structs to response. The verbs has to be given in the order in which they are expected to be executed if there is any invalid verb the function will repond with error but still Response would have all the other verbs till the invalid one
func (*Response) AddRedirect ¶
AddRedirect appends the verb to response
type Say ¶
type Say struct { XMLName xml.Name `xml:"Say"` Voice string `xml:"voice,attr,omitempty"` Language string `xml:"language,attr,omitempty"` Loop int `xml:"loop,attr,omitempty"` Text string `xml:",innerxml"` }
Say struct for the verb Say
func (*Say) SetLanguage ¶
SetLanguage sets Language for Say struct instance