Documentation
¶
Index ¶
- Constants
- func Callback(h smshandler.HTTPHandler, path string, mux *http.ServeMux, ...)
- type Bool
- type DLRPush
- type DLRStatus
- type DestinationXML
- type HTTPHandler
- type MessagesBulkXML
- type Phone
- type SMSBulkXML
- type SMSError
- type Status
- type TelzarBulkXML
- type TelzarXML
- type Unsubscribe
- type UserAuth
- type XMLResponse
Constants ¶
const ( ProdAPIAddress = `https://www.019sms.co.il/api` DevAPIAddress = `https://www.019sms.co.il:8090/api/test` HTTPContentType = `text/xml; charset=utf-8` HTTPMethod = "POST" DateFormat = "01/02/2006 15:04:05" )
Basic Addresses for contacting Telzar
Variables ¶
This section is empty.
Functions ¶
func Callback ¶ added in v0.0.8
func Callback(h smshandler.HTTPHandler, path string, mux *http.ServeMux, onCallback func(http.ResponseWriter, *http.Request, *DLRPush, error))
Callback execute on getting Push SMS back from Telzar
Types ¶
type Bool ¶
type Bool bool
Bool represents the boolean value for XML
func (Bool) MarshalXML ¶
MarshalXML implement the interface for XML Marshaling
func (*Bool) UnmarshalXML ¶
UnmarshalXML implements the interface for unmarshaling xml
type DLRPush ¶ added in v0.0.2
type DLRPush struct { ExternalID string Status Status HeMessage string EnMessage string Date time.Time Phone string Operator string ShipmentID string }
DLRPush holds information arrived from DLR sent as Push notification
func URLToDLRPush ¶ added in v0.0.2
URLToDLRPush translate url.Values to DLRPush struct
type DLRStatus ¶
type DLRStatus int
DLRStatus holds the Delivery report (DLR) information
const ( DLRStatusArrived DLRStatus = 0 DLRStatusFailed1 DLRStatus = 1 DLRStatusTimeout DLRStatus = 2 DLRStatusFailed2 DLRStatus = 3 DLRStatusCellularFailed1 DLRStatus = 4 DLRStatusFailed3 DLRStatus = 5 DLRStatusFailed4 DLRStatus = 6 DLRStatusCellularFailed2 DLRStatus = 14 DLRStatusKosherNumber DLRStatus = 15 DLRStatusDeliveryTimePermission DLRStatus = 16 DLRStatusNotArrived1 DLRStatus = 101 DLRStatusArrivedDestination DLRStatus = 102 DLRStatusExpired DLRStatus = 103 DLRStatusDeleted DLRStatus = 104 DLRStatusNotArrived2 DLRStatus = 105 DLRStatusNotArrived3 DLRStatus = 106 DLRStatusNotArrived4 DLRStatus = 107 DLRStatusRejected DLRStatus = 108 DLRStatusNotArrived5 DLRStatus = 109 DLRStatusBlockedOnRequest DLRStatus = 201 DLRStatusPermissionDenied DLRStatus = 998 DLRStatusUnknownCause DLRStatus = 999 )
DLR status codes
func (DLRStatus) MarshalXML ¶
MarshalXML implement the interface for XML Marshaling
func (*DLRStatus) UnmarshalXML ¶
UnmarshalXML implements the interface for unmarshaling xml
type DestinationXML ¶
type DestinationXML struct { XMLName xml.Name `xml:"destinations"` ClID []string `xml:"cl_id,omitempty"` Phone []Phone `xml:"phone"` }
DestinationXML represent the XML structure of destination
type HTTPHandler ¶
HTTPHandler perform HTTP actions, and implement
func (HTTPHandler) DoHTTP ¶
func (h HTTPHandler) DoHTTP( method, contentType, address string, fields url.Values, body []byte) (resp *http.Response, err error)
DoHTTP sends an HTTP Request for sending an SMS
func (HTTPHandler) OnGettingSMS ¶ added in v0.0.2
func (h HTTPHandler) OnGettingSMS(path string, mux *http.ServeMux, httpHandler http.HandlerFunc)
OnGettingSMS is an HTTP server handler when incoming SMS arrives. If mux exists, it will use it for a server, otherwise it will use http.HandleFunc.
type MessagesBulkXML ¶
type MessagesBulkXML struct { XMLName xml.Name `xml:"messages"` SMS []SMSBulkXML `xml:"sms"` Timing string `xml:"timing,omitempty"` Response Bool `xml:"response"` }
MessagesBulkXML holds a list of SMS messages for bulk sending
type SMSBulkXML ¶
type SMSBulkXML struct { XMLName xml.Name `xml:"sms"` Source string `xml:"source"` Destination DestinationXML `xml:"destination"` Message string `xml:"message"` }
SMSBulkXML holds SMS message for bulk messages
type Status ¶
type Status int
Status is the response status arrive back
const ( ErrorOK Status = 0 ErrorXMLParsing Status = 1 ErrorMissingRequiredXMLField Status = 2 ErrorIncorrectUserNameOrPassword Status = 3 ErrorNotEnoughCredit Status = 4 ErrorNoPermissionForSMS Status = 5 ErrorInvalidPhone Status = 933 ErrorSomeNumbersNotBlacklisted Status = 944 ErrorCamppaignAlreadyCanceled Status = 955 ErrorCampaignAlreadySent Status = 966 ErrorInvalidGivenCampaign Status = 977 ErrorCantUseMultipleContactLists Status = 987 ErrorContactListNotExist Status = 988 ErrorInvalidMessageLength Status = 989 ErrorAmountIsTooHighForCurrentCredit Status = 990 ErrorNonIntegerValuesForAmount Status = 991 ErrorInvalidSourceLength Status = 992 ErrorInvalidPasswordLength Status = 993 ErrorUsernameAlreadyExists Status = 994 ErrorInvalidUsernameLength Status = 995 ErrorInvalidNameLength Status = 996 ErrorInvalidCommand Status = 997 ErrorUnknownErrorInRequest Status = 998 ErrorContactSupport Status = 999 )
Error Codes
func StrToStatus ¶ added in v0.0.2
StrToStatus converts status that arrives as string to Status type. On error return -1
func (Status) MarshalXML ¶
MarshalXML implement the interface for XML Marshaling
func (*Status) UnmarshalXML ¶
UnmarshalXML implements the interface for unmarshaling xml
type TelzarBulkXML ¶
type TelzarBulkXML struct { XMLName xml.Name `xml:"bulk"` User UserAuth Messages MessagesBulkXML }
TelzarBulkXML holds full bulk XML
type TelzarXML ¶
type TelzarXML struct { XMLName xml.Name `xml:"sms"` User UserAuth `xml:"user"` Source string `xml:"source"` Destinations DestinationXML `xml:"destinations"` Tag string `xml:"tag,omitempty"` Message string `xml:"message"` AddDynamic Bool `xml:"add_dynamic,omitempty"` Timing string `xml:"timing,omitempty"` AddUnsubscribe Unsubscribe `xml:"add_unsubscribe"` Response Bool `xml:"response,omitempty"` }
TelzarXML Holds a single SMS message to send
type Unsubscribe ¶
type Unsubscribe uint8
Unsubscribe holds the type of unsubscribing methods to use
const ( UnsubscribeOff Unsubscribe = iota + 1 UnsubscribeByReturnSMS UnsubscribeByLink )
Supported types of Unsubscribe
func (Unsubscribe) MarshalXML ¶
func (u Unsubscribe) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML implement the interface for XML Marshaling
func (*Unsubscribe) Scan ¶
func (u *Unsubscribe) Scan(src interface{}) error
Scan implements the database interface for Scan
func (Unsubscribe) String ¶
func (u Unsubscribe) String() string
func (*Unsubscribe) UnmarshalXML ¶
func (u *Unsubscribe) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
UnmarshalXML implements the interface for unmarshaling xml
type UserAuth ¶
type UserAuth struct { XMLName xml.Name `xml:"user"` Username string `xml:"username"` Password string `xml:"password"` }
UserAuth holds authentication info for a request
type XMLResponse ¶
type XMLResponse struct { XMLName xml.Name `xml:"sms"` Status Status `xml:"status"` Message string `xml:"message"` ShipmentID string `xml:"shipment_id"` AddUnsubscribe Unsubscribe `xml:"add_unsubscribe,omitempty"` }
XMLResponse holds information about the given response back from the server
func (*XMLResponse) FromResponse ¶ added in v0.0.11
func (r *XMLResponse) FromResponse(buf []byte) error
FromResponse turns the body to XMLResponse, or error if something bad happened
func (XMLResponse) IsOK ¶ added in v0.0.2
func (r XMLResponse) IsOK() bool
IsOK return true if the return status is OK
func (XMLResponse) ToError ¶ added in v0.0.2
func (r XMLResponse) ToError() error
ToError converts XMLResponse to SMSError. If everything is ok, it will return nil