Documentation ¶
Index ¶
- type Config
- type SMS
- type Server
- func (s *Server) Close() error
- func (s *Server) Errors() chan error
- func (s *Server) NewMessagingService(url string, numbers ...string) (string, error)
- func (s *Server) RegisterSMSCallback(number, url string) error
- func (s *Server) RegisterVoiceCallback(number, url string) error
- func (s *Server) SMS() chan *SMS
- func (s *Server) SendSMS(from, to, body string) error
- func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (s *Server) SetCarrierInfo(number string, info twilio.CarrierInfo)
- func (s *Server) VoiceCalls() chan *VoiceCall
- type VoiceCall
- func (vc *VoiceCall) Accept()
- func (vc *VoiceCall) Body() string
- func (vc *VoiceCall) From() string
- func (vc *VoiceCall) Hangup()
- func (vc *VoiceCall) ID() string
- func (vc *VoiceCall) PressDigits(digits string)
- func (vc *VoiceCall) Reject()
- func (vc *VoiceCall) Status() twilio.CallStatus
- func (vc *VoiceCall) To() string
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.
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 (*Server) NewMessagingService ¶ added in v0.29.0
NewMessagingService registers a new Messaging SID for the given numbers.
func (*Server) RegisterSMSCallback ¶
RegisterSMSCallback will set/update a callback URL for SMS calls made to the given number.
func (*Server) RegisterVoiceCallback ¶
RegisterVoiceCallback will set/update a callback URL for voice calls made to the given number.
func (*Server) SMS ¶
SMS will return a channel that will be fed incoming SMS messages as they arrive.
func (*Server) SendSMS ¶
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 ¶
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) Hangup ¶
func (vc *VoiceCall) Hangup()
Hangup will end the call, setting it's state to "completed".
func (*VoiceCall) ID ¶
ID returns the unique ID of this phone call. It is analogous to the Twilio SID of a call.
func (*VoiceCall) PressDigits ¶
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.