vendor

package
v0.0.0-...-71395a5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2016 License: GPL-3.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInProduction    = errors.New("not in production")
	ErrSendSMSFailed      = errors.New("send sms failed")
	ErrGetStatusFailed    = errors.New("get status failed")
	ErrGetReplyFailed     = errors.New("get reply failed")
	ErrQueryBalanceFailed = errors.New("query balance failed")
	ErrVendorNotFound     = errors.New("vendor not found")
)
View Source
var (
	NameMontnets = Name("montnets")
)
View Source
var (
	NameYunpian = Name("yunpian")
)

Functions

func Prepare

func Prepare(config map[t.Channel]c.SMSConfig)

func Register

func Register(ch t.Channel, v Vendor)

Types

type Montnets

type Montnets struct {
	Username        string
	Password        string
	SendEndpoint    string
	MultiXSendPoint string
	StatusEndpoint  string
	BalanceEndpoint string
}

func NewMontnets

func NewMontnets(username, password, sendEndpoint, statusEndpoint, balanceEndpoint, multiXSendPoint string) Montnets

func (Montnets) GetBalance

func (m Montnets) GetBalance() (string, error)

func (Montnets) MultiXSend

func (m Montnets) MultiXSend(contexts []*mo.SMSContext) ([]*mo.SMSContext, error)

func (Montnets) Name

func (m Montnets) Name() Name

func (Montnets) Reply

func (m Montnets) Reply() ([]*mo.Reply, error)

func (Montnets) Send

func (m Montnets) Send(contexts []*mo.SMSContext) ([]*mo.SMSContext, error)

Send sms to given phone number with content

func (Montnets) Status

func (m Montnets) Status() ([]*mo.DeliveryStatus, error)

type Name

type Name string

type Vendor

type Vendor interface {
	Name() Name
	Send(contexts []*m.SMSContext) ([]*m.SMSContext, error)
	MultiXSend(contexts []*m.SMSContext) ([]*m.SMSContext, error)
	Status() ([]*m.DeliveryStatus, error)
	Reply() ([]*m.Reply, error)
	GetBalance() (string, error)
}

Vendor represents a SMS vendor, it can preforms two behaviors, send sms and check delivery status and pull reply.

func GetByChannel

func GetByChannel(channel t.Channel) (Vendor, error)

GetByChannel return a registered SMS vendor for given channel

func GetByName

func GetByName(name Name) ([]Vendor, error)

GetByName return a vendor for given name

type Yunpian

type Yunpian struct {
	APIKey            string
	SendEndpoint      string
	MultiSendEndpoint string
	StatusEndpoint    string
	ReplyEndpoint     string
}

func NewYunpian

func NewYunpian(apiKey, sendEndpoint, multiSendEndpoint, statusEndpoint, replyEndpoint string) Yunpian

func (Yunpian) GetBalance

func (y Yunpian) GetBalance() (string, error)

func (Yunpian) MultiXSend

func (y Yunpian) MultiXSend(contexts []*m.SMSContext) ([]*m.SMSContext, error)

func (Yunpian) Name

func (y Yunpian) Name() Name

func (Yunpian) Reply

func (y Yunpian) Reply() ([]*m.Reply, error)

func (Yunpian) Send

func (y Yunpian) Send(contexts []*m.SMSContext) error

func (Yunpian) Status

func (y Yunpian) Status() ([]*m.DeliveryStatus, error)

Jump to

Keyboard shortcuts

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