Documentation
¶
Overview ¶
Package smsgora is a Go client for the SMS Gora SMS Gateway API.
SMS Gora turns Android phones with ordinary SIM cards into an SMS gateway: your server calls the API, a linked phone sends the text, and replies and delivery reports come back to you.
Index ¶
- Constants
- func VerifyWebhook(rawBody []byte, signature, secret string) bool
- type BulkMessage
- type Client
- func (c *Client) CancelMessage(ctx context.Context, id int64) error
- func (c *Client) CreateWebhook(ctx context.Context, webhookURL string, events []string, deviceID int64) (map[string]interface{}, error)
- func (c *Client) DeleteWebhook(ctx context.Context, id int64) error
- func (c *Client) GetAccount(ctx context.Context) (map[string]interface{}, error)
- func (c *Client) GetBatch(ctx context.Context, id int64) (map[string]interface{}, error)
- func (c *Client) GetDevice(ctx context.Context, id int64) (map[string]interface{}, error)
- func (c *Client) GetMessage(ctx context.Context, id int64) (map[string]interface{}, error)
- func (c *Client) ListDevices(ctx context.Context) ([]map[string]interface{}, error)
- func (c *Client) ListMessages(ctx context.Context, filters url.Values) (interface{}, error)
- func (c *Client) ListReceivedSMS(ctx context.Context, deviceID int64, filters url.Values) (interface{}, error)
- func (c *Client) ListWebhooks(ctx context.Context) ([]map[string]interface{}, error)
- func (c *Client) Request(ctx context.Context, method, path string, body, out interface{}) error
- func (c *Client) SendBulkSMS(ctx context.Context, deviceID int64, messageTemplate string, ...) (map[string]interface{}, error)
- func (c *Client) SendSMS(ctx context.Context, p SendParams) (*SendResult, error)
- type Error
- type SendParams
- type SendResult
Constants ¶
const DefaultBaseURL = "https://tekservix.com/smsgora/api/v1"
DefaultBaseURL is the SMS Gora API endpoint.
const Version = "1.0.1"
Version of this client.
Variables ¶
This section is empty.
Functions ¶
func VerifyWebhook ¶
VerifyWebhook checks the X-SmsGora-Signature header (sha256=<hex HMAC-SHA256 of the raw body>). Pass the raw request body, before JSON decoding.
Types ¶
type BulkMessage ¶
type BulkMessage struct {
Recipients []string `json:"recipients"`
Message string `json:"message,omitempty"`
}
BulkMessage is one entry of SendBulkSMS.
type Client ¶
Client talks to the SMS Gora API. Create one with New and reuse it.
func (*Client) CancelMessage ¶
CancelMessage cancels a queued or scheduled message.
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(ctx context.Context, webhookURL string, events []string, deviceID int64) (map[string]interface{}, error)
CreateWebhook registers a webhook. The answer includes the secret (only returned once). events defaults to ["sms.received"]; deviceID 0 means all phones.
func (*Client) DeleteWebhook ¶
DeleteWebhook removes a webhook.
func (*Client) GetAccount ¶
GetAccount returns your account, plan and usage.
func (*Client) GetMessage ¶
GetMessage returns one message. Status is queued, dispatched, sent, delivered, failed or cancelled.
func (*Client) ListDevices ¶
ListDevices lists your linked Android phones.
func (*Client) ListMessages ¶
ListMessages lists messages. Filters: direction (in/out), status, device_id, phone, since, after_id, page, limit.
func (*Client) ListReceivedSMS ¶
func (c *Client) ListReceivedSMS(ctx context.Context, deviceID int64, filters url.Values) (interface{}, error)
ListReceivedSMS lists incoming SMS for all phones (deviceID 0) or one phone.
func (*Client) ListWebhooks ¶
ListWebhooks lists webhooks registered by API.
func (*Client) Request ¶
Request calls any documented endpoint and decodes the `data` field into out (which may be nil).
func (*Client) SendBulkSMS ¶
func (c *Client) SendBulkSMS(ctx context.Context, deviceID int64, messageTemplate string, messages []BulkMessage) (map[string]interface{}, error)
SendBulkSMS sends different texts to different people in one call (up to 5,000 recipients). Entries without their own Message use messageTemplate.
func (*Client) SendSMS ¶
func (c *Client) SendSMS(ctx context.Context, p SendParams) (*SendResult, error)
SendSMS sends an SMS. It picks your best online phone unless DeviceID is set.
type Error ¶
type Error struct {
Status int // HTTP status code
Message string // message from the API
Errors map[string][]string // field errors, if any
Body []byte // raw answer
RetryAfter time.Duration // set on HTTP 429
}
Error is returned when the API answers with an error.
type SendParams ¶
type SendParams struct {
To []string // up to 1,000 numbers in international format
Message string // up to 1,600 characters
DeviceID int64 // optional: send from this phone
SimSlot *int // optional: 0 = SIM 1, 1 = SIM 2
ScheduleAt *time.Time // optional: send later
}
SendParams describes an SMS to send.
type SendResult ¶
type SendResult struct {
MessageIDs []int64 `json:"message_ids"`
BatchID *int64 `json:"batch_id,omitempty"`
Status string `json:"status,omitempty"`
}
SendResult is returned by SendSMS.