multisendsms

package module
v0.0.0-...-8aa86f7 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

README

note: the API of the service is unstable, and therefore I will not support it at this time.

Documentation

Index

Constants

View Source
const (
	DefaultHTTPAddress     = "https://api.multisend.co.il/MultiSendAPI/"
	DefaultSendSMSPage     = "sendsms"
	DefaultDateTimeFormat  = "2006-02-01+15:04:05"
	DefaultGETContentType  = "text/plain; charset=UTF-8"
	DefaultPOSTContentType = "application/x-www-form-urlencoded"
)

Default settings

Variables

This section is empty.

Functions

This section is empty.

Types

type Bool

type Bool bool

Bool is a boolean that understand also numeric values

func (Bool) Int

func (b Bool) Int() int

Int returns int from Bool

func (*Bool) Scan

func (b *Bool) Scan(src interface{}) error

Scan implements the database interface for Scan

func (Bool) Uint

func (b Bool) Uint() uint

Uint returns int from Bool

func (Bool) Value

func (b Bool) Value() (driver.Value, error)

Value implements the database interface of Value

type DLRType

type DLRType string

DLRType holds information regarding the DLR

const (
	DLRTypeSuccess             DLRType = "888"
	DLRTypeNumberWithoutDevice DLRType = "000"
	DLRTypeDeviceMemoryFull1   DLRType = "003"
	DLRTypeFilteredMessage     DLRType = "009"
	DLRTypeDeviceNotSupported  DLRType = "012"
	DLRTypeServiceNotSupported DLRType = "021"
	DLRTypeDeviceMemoryFull2   DLRType = "032"
	DLRTypeMessageExpired      DLRType = "041"
)

The Types of given DLR

func (DLRType) Error

func (dlr DLRType) Error() string

Error returns an error from DLR

func (*DLRType) Scan

func (dlr *DLRType) Scan(src interface{}) error

Scan implements the database interface for Scan

func (DLRType) Value

func (dlr DLRType) Value() (driver.Value, error)

Value implements the database interface of Value

type MessageType

type MessageType uint

MessageType is the type of message to tell the API to use

const (
	MessageTypeUnknown MessageType = iota
	MessageTypeTTS
	MessageTypeSMS
	MessageTypeSMSAndTTS
)

Type Of messages to use

func (*MessageType) Scan

func (mt *MessageType) Scan(src interface{}) error

Scan implements the database interface for Scan

func (MessageType) String

func (mt MessageType) String() string

func (MessageType) Value

func (mt MessageType) Value() (driver.Value, error)

Value implements the database interface of Value

type RESTSendSMS

type RESTSendSMS struct {
	UserName                   string            `url:"user"`
	Password                   string            `url:"password"`
	From                       string            `url:"from"`
	Recipient                  Recipients        `url:"recipient"`
	Message                    string            `url:"message"`
	MessageType                MessageType       `url:"message_type,omitempty"`
	ScheduleDateTime           SchedulerDateTime `url:"scheduledatetime,omitempty"`
	International              Bool              `url:"international,omitempty"`
	DeliveryNotificationURL    string            `url:"deliverynotification_url,omitempty"`
	CustomerMessageID          string            `url:"customermessageid,omitempty"`
	DeliveryNotificationMethod string            `url:"deliverynotificationmethod,omitempty"`
	SendID                     string            `url:"sendID,omitempty"`
}

RESTSendSMS holds the fields to send SMS using GET and POST requests

func (RESTSendSMS) SendSMS

func (r RESTSendSMS) SendSMS(
	method string, client *http.Client, onResponse smshandler.Response) (*http.Response, error)

SendSMS sends the SMS implementing the RESTHandler interface

func (*RESTSendSMS) ToURL

func (r *RESTSendSMS) ToURL() url.Values

ToURL converts the struct to url.Values

type Recipients

type Recipients []string

Recipients holds a list of recipients to send them SMS

func (*Recipients) Add

func (r *Recipients) Add(number string)

Add a new number for the recipients

func (Recipients) IsNumberExists

func (r Recipients) IsNumberExists(number string) (bool, int)

IsNumberExists searches for a number if exists on the Recipients list if found returns true and the index

func (*Recipients) RemoveByIndex

func (r *Recipients) RemoveByIndex(idx int) error

RemoveByIndex removes a number from Recipients based on an index if index is too small or too big, an error is raised

func (*Recipients) Scan

func (r *Recipients) Scan(src interface{}) error

Scan implements the database interface for Scan

func (Recipients) String

func (r Recipients) String() string

func (Recipients) Value

func (r Recipients) Value() (driver.Value, error)

Value implements the database interface of Value

type Response

type Response struct {
	Success  bool           `json:"success"`
	Message  string         `json:"message,omitempty"`
	SMSCount int            `json:"smsCount,omitempty"`
	Error    ResponseErrors `json:"error,omitempty"`
}

Response holds the structure for response messages

func (*Response) FromResponse

func (r *Response) FromResponse(status []byte) error

FromResponse implements the interface of Response

func (Response) IsOK

func (r Response) IsOK() bool

IsOK implements the interface of Response

func (*Response) ToError

func (r *Response) ToError() error

ToError implements the interface of Response

type ResponseErrors

type ResponseErrors map[string]string

ResponseErrors is a map for holding error messages arrives from the Response

type SchedulerDateTime

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

SchedulerDateTime holds date and time format to schedule sms

func NewSchedulerDateTime

func NewSchedulerDateTime(str string) (*SchedulerDateTime, error)

NewSchedulerDateTime initialize a new SchedulerDateTime.

func NewSchedulerFromTime

func NewSchedulerFromTime(t time.Time) *SchedulerDateTime

NewSchedulerFromTime initialize a new SchedulerDateTime from time.Time

func (SchedulerDateTime) IsValid

func (dt SchedulerDateTime) IsValid() bool

IsValid returns true if the date is valid

func (*SchedulerDateTime) Scan

func (dt *SchedulerDateTime) Scan(src interface{}) error

Scan implements the database interface for Scan

func (*SchedulerDateTime) SetDateTime

func (dt *SchedulerDateTime) SetDateTime(dateTime time.Time)

SetDateTime update SchedulerDateTime to a new date time

func (SchedulerDateTime) String

func (dt SchedulerDateTime) String() string

func (SchedulerDateTime) Value

func (dt SchedulerDateTime) Value() (driver.Value, error)

Value implements the database interface of Value

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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