sms

package
v0.0.0-...-83e654d Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SMSSchema       = "sms_notifications"
	SMSDefaultTopic = "/sms"
)

Variables

View Source
var (
	URL                = "https://rest.nexmo.com/sms/json?"
	MaxIdleConnections = 100
	RequestTimeout     = 500 * time.Millisecond
)
View Source
var (
	ErrNoSMSSent                 = errors.New("No sms was sent to Nexmo")
	ErrIncompleteSMSSent         = errors.New("Nexmo sms was only partial delivered.One or more part returned an error")
	ErrSMSResponseDecodingFailed = errors.New("Nexmo response decoding failed.")
	ErrNoRetry                   = errors.New("SMS failed. No retrying.")
)
View Source
var (
	ErrRetryFailed = errors.New("Failed retrying to send message.")
)

Functions

func New

func New(router router.Router, sender Sender, config Config) (*gateway, error)

Types

type Config

type Config struct {
	Enabled         *bool
	APIKey          *string
	APISecret       *string
	Workers         *int
	SMSTopic        *string
	IntervalMetrics *bool

	Name   string
	Schema string
}

type NexmoMessageReport

type NexmoMessageReport struct {
	Status           ResponseCode `json:"status,string"`
	MessageID        string       `json:"message-id"`
	To               string       `json:"to"`
	ClientReference  string       `json:"client-ref"`
	RemainingBalance string       `json:"remaining-balance"`
	MessagePrice     string       `json:"message-price"`
	Network          string       `json:"network"`
	ErrorText        string       `json:"error-text"`
}

NexmoMessageReport is the "status report" for a single SMS sent via the Nexmo API

type NexmoMessageResponse

type NexmoMessageResponse struct {
	MessageCount int                  `json:"message-count,string"`
	Messages     []NexmoMessageReport `json:"messages"`
}

func (NexmoMessageResponse) Check

func (nm NexmoMessageResponse) Check() error

type NexmoSender

type NexmoSender struct {
	ApiKey    string
	ApiSecret string
	// contains filtered or unexported fields
}

func NewNexmoSender

func NewNexmoSender(apiKey, apiSecret string) (*NexmoSender, error)

func (*NexmoSender) Send

func (ns *NexmoSender) Send(msg *protocol.Message) error

type NexmoSms

type NexmoSms struct {
	ApiKey    string `json:"api_key,omitempty"`
	ApiSecret string `json:"api_secret,omitempty"`
	To        string `json:"to"`
	From      string `json:"from"`
	Text      string `json:"text"`
}

func (*NexmoSms) EncodeNexmoSms

func (sms *NexmoSms) EncodeNexmoSms(apiKey, apiSecret string) ([]byte, error)

type ResponseCode

type ResponseCode int
const (
	ResponseSuccess ResponseCode = iota
	ResponseThrottled
	ResponseMissingParams
	ResponseInvalidParams
	ResponseInvalidCredentials
	ResponseInternalError
	ResponseInvalidMessage
	ResponseNumberBarred
	ResponsePartnerAcctBarred
	ResponsePartnerQuotaExceeded
	ResponseUnused
	ResponseRESTNotEnabled
	ResponseMessageTooLong
	ResponseCommunicationFailed
	ResponseInvalidSignature
	ResponseInvalidSenderAddress
	ResponseInvalidTTL
	ResponseFacilityNotAllowed
	ResponseInvalidMessageClass
)

func (ResponseCode) String

func (c ResponseCode) String() string

type Sender

type Sender interface {
	Send(*protocol.Message) error
}

Jump to

Keyboard shortcuts

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