cellsynt

package module
v0.0.0-...-2e5629c Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

README

cellsynt

Cellsynt API lib in Go

wercker status Coverage Status GoDoc

Create a client

A client is used when communicating with Cellsynt.

client := cellsynt.NewClient(username, username, senderName),

You can create the client directly with some non-default values:

client := &cellsynt.Client{
    Username:       username,
    Password:       password,
    OriginatorType: OriginatorTypeAlpha,
    Originator:     senderName,
    Charset:        CharsetUTF8,
    AllowConcat:    true,
}
Send a text
textMsg := &cellsynt.TextMessage{
    Destination: &cellsynt.Destination{
        Recipients: []string{"555-123-45"},
    },
    Text:    message.Body,
    Charset: cellsynt.CharsetUTF8,
}
_, err = client.SendMessage(textMsg)
if err != nil {
    ...
}

Override client options by including them in the message:

textMsg := &cellsynt.TextMessage{
    Destination: &cellsynt.Destination{
        Recipients: []string{"555-123-45"},
    },
    Options: &cellsynt.Options{
        OriginatorType: OriginatorTypeNumeric,
        Originator:     "0703112233",
    },
    Text:    message.Body,
}
_, err = client.SendMessage(textMsg)

A tracking ID is returned for each destination

response, _ = client.SendMessage(textMsg)
print(response)
&Response{
    Success: true,
    TrackingIDs: []string{
        "de8c4a032fb45ae65ab9e349a8dc2458",
    },
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BinaryMessage

type BinaryMessage struct {
	Binary []byte
	UDH    []byte

	*Destination
	*Options
}

BinaryMessage can be used to send settings, bookmarks, visiting cards etc. See relevant phone manufacturer's manual for further specifications on message formats available. Two parameters are needed to send the binary data: udh and data. Parameters can be set individually, it is not mandatory to use both, however, at least one of them

func (*BinaryMessage) GetParameters

func (m *BinaryMessage) GetParameters() map[string]string

GetParameters implements Message interface

func (*BinaryMessage) Type

func (m *BinaryMessage) Type() string

Type returns the message type

type ByKey

type ByKey []string

ByKey is sorting of parameter fields by key

func (ByKey) Len

func (s ByKey) Len() int

func (ByKey) Less

func (s ByKey) Less(i, j int) bool

func (ByKey) Swap

func (s ByKey) Swap(i, j int)

type Charset

type Charset string
const (
	CharsetUTF8     Charset = "UTF-8"
	CharsetISO88591 Charset = "ISO-8859-1"
)

type Client

type Client struct {
	// Required
	Username string
	Password string

	// Default values, can be overridden by message values.
	OriginatorType     OriginatorType
	Originator         string
	Charset            Charset
	AllowConcat        bool
	DefaultCountryCode string
}

Client holds username and password, and default values for messages The values on the client are default values that can be overridden by a message with different value for a field.

func NewClient

func NewClient(username, password string, senderName string) *Client

NewClient returns a new client instance with some defaults set SenderName is the originator, alpha numeric string by default

func (*Client) SendMessage

func (c *Client) SendMessage(message Message) (*Response, error)

SendMessage dispatches a message to the destination

type Destination

type Destination struct {
	// Required
	Recipients []string

	// Optional, can be included in destination
	DefaultCountryCode string
}

Destination contains default values that all message types share. Theese values can be omitted if you want to use the client default

func (*Destination) Destinations

func (b *Destination) Destinations() string

Destination is the Destination address(es) formatted for cellsynt

func (*Destination) GetParameters

func (b *Destination) GetParameters() map[string]string

type FlashMessage

type FlashMessage struct {
	// Required
	Text string

	// Optional
	Charset     Charset
	AllowConcat bool

	*Destination
	*Options
}

FlashMessage is used to send a normal text message which is shown directly on screen instead of being saved in the inbox on the recipient's mobile phone ("flash message"). Please note! Support for flash messages can vary depending on mobile phone model, operator network and other external factors. If it is not possible to send a mess

func (*FlashMessage) GetParameters

func (m *FlashMessage) GetParameters() map[string]string

GetParameters implements Message interface

func (*FlashMessage) Type

func (m *FlashMessage) Type() string

Type returns the message type

type Message

type Message interface {
	Type() string
	Destinations() string
	GetParameters() map[string]string
}

Message is a generic interface to all types of messages

type Options

type Options struct {
	// Optional
	OriginatorType OriginatorType
	Originator     string
}

func (*Options) GetParameters

func (b *Options) GetParameters() map[string]string

type OriginatorType

type OriginatorType string
const (
	OriginatorTypeNumeric   OriginatorType = "numeric"
	OriginatorTypeShortcode OriginatorType = "shortcode"
	OriginatorTypeAlpha     OriginatorType = "alpha"
)

type Response

type Response struct {
	Success     bool
	TrackingIDs []string
}

Response will contain a success flag and the tracking ids that can be used for status tracking messages

type TextMessage

type TextMessage struct {
	// Required
	Text string

	// Optional
	Charset     Charset
	AllowConcat bool

	*Destination
	*Options
}

TextMessage is used to send a normal text message. Maximum number of characters is 160. Any characters specified within character coding GSM 03.38 can be used (e.g. English, Swedish, Norwegian), for other languages / alphabets (e.g. Arabic, Japanese, Chinese) please use Unicode.

func (*TextMessage) GetParameters

func (m *TextMessage) GetParameters() map[string]string

GetParameters implements Message interface

func (*TextMessage) Type

func (m *TextMessage) Type() string

Type returns the message type

type UnicodeMessage

type UnicodeMessage struct {
	// Required
	Text string

	// Optional
	Charset     Charset
	AllowConcat bool

	*Destination
	*Options
}

UnicodeMessage can be used if you need to send characters not available within an ordinary text message (e.g. Arabic, Japanese). A Unicode SMS can contain maximum 70 characters per message (or 67 characters per part for a long SMS). Unicode messages are sent by setting parameter type to unicode. When sending Unicode messages, the parameter charset can be set to UTF-8 to send data in the UTF-8 character set instead which holds characters of most of the world's languages.

func (*UnicodeMessage) GetParameters

func (m *UnicodeMessage) GetParameters() map[string]string

GetParameters implements Message interface

func (*UnicodeMessage) Type

func (m *UnicodeMessage) Type() string

Type returns the message type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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