mocktwilio

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: Apache-2.0 Imports: 17 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 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) Close added in v0.24.0

func (s *Server) Close() error

Close will shutdown the server loop.

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) error

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) SetCarrierInfo added in v0.25.0

func (s *Server) SetCarrierInfo(number string, info twilio.CarrierInfo)

SetCarrierInfo will set/update the carrier info (used for the Lookup API) for the given number.

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) Body added in v0.25.0

func (vc *VoiceCall) Body() string

Body will return the last spoken message of the call.

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) PressDigits

func (vc *VoiceCall) PressDigits(digits string)

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

func (*VoiceCall) Reject

func (vc *VoiceCall) Reject()

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

func (*VoiceCall) Status added in v0.25.0

func (vc *VoiceCall) Status() twilio.CallStatus

Status will return the current status of the call.

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