gosmsc

package module
v0.0.0-...-fedd180 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2014 License: MIT Imports: 12 Imported by: 0

README

gosmsc

A Golang wrapper around the smsc.ru https API. Currently supports minimal set of features needed to send sms. May be extended in future.

Installation

go get github.com/goodsign/gosmsc

API

https://smsc.ru/api/http/

Licence

MIT

Documentation

Index

Constants

View Source
const (
	DefaultUpdateInterval = time.Minute
)

Variables

View Source
var (
	MessageNotFound  = errors.New("Message not found")
	MessageSuspended = errors.New("Message suspended")
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output

func FlushLog

func FlushLog()

Call this before app shutdown

func UseLogger

func UseLogger(newLogger log.LoggerInterface)

UseLogger uses a specified seelogger.LoggerInterface to output library logger. Use this func if you are using Seelog logging system in your app.

Types

type MessageStatusMgoStorage

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

MessageStatusMgoStorage is a default mgo implementation of the MessageStatusStorageInterface.

func NewMessageStatusMgoStorage

func NewMessageStatusMgoStorage(dbHelper *mgohelper.DbHelper) (*MessageStatusMgoStorage, error)

func (*MessageStatusMgoStorage) Get

func (ms *MessageStatusMgoStorage) Get(messageId int64) (*MessageStatus, error)

func (*MessageStatusMgoStorage) GetPending

func (ms *MessageStatusMgoStorage) GetPending() ([]MessageStatus, error)

func (*MessageStatusMgoStorage) Put

func (ms *MessageStatusMgoStorage) Put(message *MessageStatus) error

type MessageTracker

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

MessageTracker represents a running goroutine that polls SMSC service to track status of sent messages which status is pending. This object is created when a goroutine is started by StartTracking and can be used to stop the goroutine using Close func. After goroutine is stopped by Close() this object cannot be used anymore.

func StartTracking

func StartTracking(storage StatusContainer, statusFetcher StatusFetcher, updateInterval time.Duration) (tracker *MessageTracker, e error)

StartTracking creates a new tracker for the specified storage and starts the tracking process in a separate goroutine. Uses 'statusFetcher' argument to call the SMSC service when updates for pending messages are needed. To stop it, call Close on the returned tracker instance.

func (*MessageTracker) IsStopped

func (t *MessageTracker) IsStopped() bool

IsStopped returns true if the tracker goroutine was stopped by the Stop func and the tracker is unusable anymore.

func (*MessageTracker) Stop

func (t *MessageTracker) Stop() error

Stop stops the polling goroutine and closes the tracker object. A stopped tracker cannot be used anymore.

NOTE 1: Goroutine doesn't terminate immediately (it can be processing pending issues), but Stop func is non blocking itself.

type SenderCheckerImpl

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

HttpSenderChecker provides the functionality to send sms and track its status.

It consists of a sender, status getter, message storage, and a tracker goroutine. When sms is sent using 'Send', SenderChecker implementation adds a 'pending' entry to the storage. Then the tracker goroutine starts polling the smsc gateway using the status getter. It polls it until message is delivered and updates the message status in the storage each time.

It can be also used without tracking functionality. See 'track' flag in the Send func.

func NewSenderCheckerImpl

func NewSenderCheckerImpl(opts *SmscClientOptions, storage StatusContainer, updateInterval time.Duration) (*SenderCheckerImpl, error)

func (*SenderCheckerImpl) GetActualStatus

func (c *SenderCheckerImpl) GetActualStatus(id int64) (*MessageStatus, error)

func (*SenderCheckerImpl) Send

func (c *SenderCheckerImpl) Send(phone string, text string, track bool) (int64, error)

type SenderFetcherImpl

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

SenderFetcherImpl is a plain implementation of Sender and StatusFetcher interfaces that interacts with SMSC web gateway. Unlike SenderCheckerImpl, SenderFetcherImpl doesn't track or store anything, it is just a gateway caller without any side-effects.

func NewSenderFetcherImpl

func NewSenderFetcherImpl(opts *SmscClientOptions) (*SenderFetcherImpl, error)

func (*SenderFetcherImpl) FetchStatus

func (c *SenderFetcherImpl) FetchStatus(id int64, phone string) (*CheckStatusResponse, error)

func (*SenderFetcherImpl) Send

func (c *SenderFetcherImpl) Send(phone string, text string) (*SendSMSResponse, error)

type SmscClientOptions

type SmscClientOptions struct {
	User     string `json:"user"`
	Password string `json:"pwd"`
}

SmscClientOptions encapsulates configuration used to send sms messages using smsc.ru

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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