Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) CancelMessageStatus(messageIds []string) (*MessageStatusResponse, error)
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Get(url string) (*http.Response, error)
- func (c *Client) NewRequest(method, urlStr string, body io.Reader) (*http.Request, error)
- func (c *Client) Post(url string, bodyType string, body io.Reader) (*http.Response, error)
- func (c *Client) QueryAccountPoint() (int, error)
- func (c *Client) QueryMessageStatus(messageIds []string) (*MessageStatusResponse, error)
- func (c *Client) Send(message Message) (*MessageResponse, error)
- func (c *Client) SendBatch(messages []Message) (*MessageResponse, error)
- type Message
- type MessageReceipt
- type MessageResponse
- type MessageResult
- type MessageStatus
- type MessageStatusResponse
- type StatusCode
Constants ¶
const ( StatusServiceError = StatusCode("*") StatusUsernameRequired = StatusCode("c") StatusPasswordRequired = StatusCode("d") StatusUsernameOrPasswordError = StatusCode("e") StatusAccountExpired = StatusCode("f") StatusAccountDisabled = StatusCode("h") StatusInvalidConnectionAddress = StatusCode("k") StatusReachConnectUserLimit = StatusCode("l") StatusChangePasswordRequired = StatusCode("m") StatusPasswordExpired = StatusCode("n") StatusPermissionDenied = StatusCode("p") StatusAccountingFailure = StatusCode("s") StatusSMSExpired = StatusCode("t") StatusSMSBodyEmpty = StatusCode("u") StatusInvalidPhoneNumber = StatusCode("v") StatusQueryRecordExceededLimit = StatusCode("w") StatusSMSSizeTooLarge = StatusCode("x") StatusParameterError = StatusCode("y") StatusNoRecord = StatusCode("z") StatusReservationForDelivery = StatusCode("0") StatusCarrierAccepted = StatusCode("1") StatusCarrierAccepted2 = StatusCode("2") StatusCarrierAccepted3 = StatusCode("3") StatusDelivered = StatusCode("4") StatusContentError = StatusCode("5") StatusPhoneNumberError = StatusCode("6") StatusSMSDisable = StatusCode("7") StatusDeliveryTimeout = StatusCode("8") StatusReservationCanceled = StatusCode("9") )
List of Mitake API status codes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
A Client manages communication with the Mitake API.
func NewClient ¶
NewClient returns a new Mitake API client. The username and password are required for authentication. If a nil httpClient is provided, http.DefaultClient will be used.
func (*Client) CancelMessageStatus ¶
func (c *Client) CancelMessageStatus(messageIds []string) (*MessageStatusResponse, error)
CancelMessageStatus cancel the specific messages.
func (*Client) Do ¶
Do sends an API request, and returns the API response. If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash.
func (*Client) QueryAccountPoint ¶
QueryAccountPoint retrieves your account balance.
func (*Client) QueryMessageStatus ¶
func (c *Client) QueryMessageStatus(messageIds []string) (*MessageStatusResponse, error)
QueryMessageStatus fetch the status of specific messages.
type Message ¶
type Message struct {
Dstaddr string `json:"dstaddr"` // Destination phone number
Destname string `json:"destname"` // Destination receiver name
Dlvtime string `json:"dlvtime"` // Optional, Delivery time
Vldtime string `json:"vldtime"` // Optional
Smbody string `json:"smbody"` // The text of the message you want to send
Response string `json:"response"` // Optional, Callback URL to receive the delivery receipt of the message
ClientID string `json:"clientid"` // Optional (required when bulk send), an unique identifier from client to identify SMS message
}
Message represents an SMS object.
func (Message) ToBatchMessage ¶
ToBatchMessage returns the format string for multiple SMS.
type MessageReceipt ¶
type MessageReceipt struct {
Msgid string `json:"msgid"`
Dstaddr string `json:"dstaddr"`
Dlvtime string `json:"dlvtime"`
Donetime string `json:"donetime"`
Statuscode string `json:"statuscode"`
Statusstring StatusCode `json:"statusstring"`
Statusstr string `json:"statusstr"`
StatusFlag string `json:"StatusFlag"`
}
MessageReceipt represents a message delivery receipt.
func ParseMessageReceipt ¶
func ParseMessageReceipt(r *http.Request) (*MessageReceipt, error)
ParseMessageReceipt parse an incoming Mitake callback request and return the MessageReceipt.
Example usage:
func Callback(w http.ResponseWriter, r *http.Request) {
receipt, err := mitake.ParseMessageReceipt(r)
if err != nil { ... }
// Process message receipt
}
type MessageResponse ¶
type MessageResponse struct {
Results []*MessageResult
AccountPoint int
INI string `json:"-"`
}
MessageResponse represents response of send SMS.
type MessageResult ¶
type MessageResult struct {
ClientID string `json:"clientid"`
Msgid string `json:"msgid"`
Statuscode string `json:"statuscode"`
Statusstring StatusCode `json:"statusstring"`
Duplicate string `json:"Duplicate"`
}
MessageResult represents result of send SMS.
type MessageStatus ¶
type MessageStatus struct {
MessageResult
StatusTime string `json:"statustime"`
}
MessageStatus represents status of message.
type MessageStatusResponse ¶
type MessageStatusResponse struct {
Statuses []*MessageStatus
INI string `json:"-"`
}
MessageStatusResponse represents response of query message status.
type StatusCode ¶
type StatusCode string
StatusCode of Mitake API.
func (StatusCode) String ¶
func (c StatusCode) String() string