sms

package
v0.0.0-...-b4df255 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: MIT Imports: 18 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

	ErrHTTPClientError           = errors.New("Http client sending to Nexmo Failed. No sms was sent")
	ErrNexmoResponseStatusNotOk  = errors.New("Nexmo response status not ResponseSuccess")
	ErrSMSResponseDecodingFailed = errors.New("Nexmo response decoding failed")
	ErrInvalidSender             = errors.New("Sms destination phoneNumber is invalid")
	ErrMultipleSmsSent           = errors.New("Multiple or no sms were sent. SMS message may be too long")
	ErrRetryFailed               = errors.New("Failed retrying to send message")
	ErrEncodeFailed              = errors.New("Encoding of message to be sent to Nexmo failed")
	ErrLastIDCouldNotBeSet       = errors.New("Setting last id failed")

	ErrSmsTooLong = errors.New("Sms maximum length exceeded")
)

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
	Toggleable      *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, kafkaProducer kafka.Producer, kafkaReportingTopic 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"`
	ClientRef string `json:"client-ref"`
}

func (*NexmoSms) EncodeNexmoSms

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

type ReportEvent

type ReportEvent struct {
	Id      string        `json:"id"`
	Time    string        `json:"time"`
	Type    string        `json:"type"`
	Payload ReportPayload `json:"payload"`
}

type ReportPayload

type ReportPayload struct {
	OrderID         string `json:"order_id,omitempty"`
	MessageID       string `json:"message_id"`
	SmsText         string `json:"text"`
	SmsRequestTime  string `json:"request_time"`
	SmsResponseTime string `json:"response_time"`
	MobileNumber    string `json:"mobile_number"`
	DeliveryStatus  string `json:"delivery_status"`
}

type ResponseCode

type ResponseCode int
const (
	ResponseSuccess ResponseCode = iota
	ResponseThrottled
	ResponseMissingParams
	ResponseInvalidParams
	ResponseInvalidCredentials
	ResponseInternalError
	ResponseInvalidMessage
	ResponseNumberBarred
	ResponsePartnerAcctBarred
	ResponsePartnerQuotaExceeded
	ResponseUnused //Defined in Nexmo Api
	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