sms

package
v0.0.0-...-d22e7c3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client sms module for nexmo

func New

func New(config Config) (*Client, error)

New nexmo sms module

func (*Client) Callback

func (c *Client) Callback()

Callback to handle callback from nexmo

func (*Client) Send

func (c *Client) Send(ctx context.Context, payload Payload) (Response, error)

Send sms using nexmo currently, the API only expect to send 1 message

type Config

type Config struct {
	APIKey           string
	APISecret        string
	Endpoint         string
	CallbackEndpoint string
}

Config of nexmo

func (*Config) Validate

func (c *Config) Validate() error

Validate nexmo config

type NexmoSMSCallback

type NexmoSMSCallback struct {
	// the number that message sent to
	MSISDN string `json:"msisdn"`
	// this is the sender_id
	To          string `json:"to"`
	NetworkCode string `json:"network_code"`
	// message_id from nexmo
	MessageID string `json:"message_id"`
	// price of the message
	Price string `json:"price"`
	// status of delivery
	Status string `json:"status"`
	Scts   string `json:"scts"`
	// should be not 0 if error
	ErrCode string `json:"err-code"`
	// date of webhook triggered
	MessageTimestamp string `json:"message_timestamp"`
}

NexmoSMSCallback data

type Payload

type Payload struct {
	From    string
	To      string
	Message string
}

Payload of sms

type Request

type Request struct {
	APIKey    string `json:"api_key"`
	APISecret string `json:"api_secret"`
	// hash of request parameter
	Sig  string `json:"sig"`
	From string `json:"from"`
	To   string `json:"to"`
	Text string `json:"text"`
	// NOT REQUIRED, nexmo attempt to delivery
	TTL int `json:"ttl"`
	// status report by nexmo
	StatusReportReq bool `json:"status-report-req"`
	// where the callback is going to, nexmo will send back the status of send
	Callback string `json:"callback"`
	Type     string `json:"type"`
}

Request data

type Response

type Response struct {
	MessageCount string `json:"message-count"`
	Messages     []struct {
		To               string `json:"to"`
		MessageID        string `json:"message_id"`
		Status           string `json:"status"`
		RemainingBalance string `json:"remaining_balance"`
		MessagePrice     string `json:"message-price"`
		Network          string `json:"network"`
		ErrorText        string `json:"error-text"`
	} `json:"messages"`
}

Response struct

Jump to

Keyboard shortcuts

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