mocktwilio

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {

	// The SID and token should match values given to the backend
	// as the mock server will send and validate signatures.
	AccountSID string
	AuthToken  string

	// MinQueueTime determines the minimum amount of time an SMS or voice
	// call will sit in the queue before being processed/delivered.
	MinQueueTime time.Duration
}

Config is used to configure the mock server.

type SMS

type SMS struct {
	// contains filtered or unexported fields
}

SMS represents an SMS message.

func (*SMS) Accept

func (sms *SMS) Accept()

Accept will cause the SMS to be marked as delivered.

func (*SMS) Body

func (sms *SMS) Body() string

Body returns the contents of the SMS message.

func (*SMS) From

func (sms *SMS) From() string

From returns the phone number the SMS was sent from.

func (*SMS) ID

func (sms *SMS) ID() string

ID will return the unique ID for this SMS.

func (*SMS) Reject

func (sms *SMS) Reject()

Reject will cause the SMS to be marked as undelivered (failed).

func (*SMS) To

func (sms *SMS) To() string

To returns the phone number the SMS is being sent to.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements the Twilio API for SMS and Voice calls via the http.Handler interface.

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new Server.

func (*Server) Errors

func (s *Server) Errors() chan error

Errors returns a channel that gets fed all errors when calling the backend.

func (*Server) RegisterSMSCallback

func (s *Server) RegisterSMSCallback(number, url string) error

RegisterSMSCallback will set/update a callback URL for SMS calls made to the given number.

func (*Server) RegisterVoiceCallback

func (s *Server) RegisterVoiceCallback(number, url string) error

RegisterVoiceCallback will set/update a callback URL for voice calls made to the given number.

func (*Server) SMS

func (s *Server) SMS() chan *SMS

SMS will return a channel that will be fed incomming SMS messages as they arrive.

func (*Server) SendSMS

func (s *Server) SendSMS(from, to, body string)

SendSMS will cause an SMS to be sent to the given number with the contents of body.

The to parameter must match a value passed to RegisterSMSCallback or an error is returned.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface for serving [mock] API requests.

func (*Server) VoiceCalls

func (s *Server) VoiceCalls() chan *VoiceCall

VoiceCalls will return a channel that will be fed VoiceCalls as they arrive.

type VoiceCall

type VoiceCall struct {
	// contains filtered or unexported fields
}

VoiceCall represents a voice call session.

func (*VoiceCall) Accept

func (vc *VoiceCall) Accept()

Accept will allow a call to move from initiated to "in-progress".

func (*VoiceCall) From

func (vc *VoiceCall) From() string

From return the source phone number.

func (*VoiceCall) Hangup

func (vc *VoiceCall) Hangup()

Hangup will end the call, setting it's state to "completed".

func (*VoiceCall) ID

func (vc *VoiceCall) ID() string

ID returns the unique ID of this phone call. It is analogus to the Twilio SID of a call.

func (*VoiceCall) Message

func (vc *VoiceCall) Message() string

Message will return the last spoken message of the call.

func (*VoiceCall) PressDigits

func (vc *VoiceCall) PressDigits(digits string)

PressDigits will re-query for a spoken message with the given digits.

It also causes the result of Listen() to be blank until a new message is gathered.

func (*VoiceCall) Reject

func (vc *VoiceCall) Reject()

Reject will reject a call, moving it to a "failed" state.

func (*VoiceCall) To

func (vc *VoiceCall) To() string

To returns the destination phone number.

Jump to

Keyboard shortcuts

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