AtEx v0.20.21 AtEx.Gateway.Sms.Bulk View Source
This module holds the implementation for the HTTP Gateway that runs calls against the Africas Talking API SMS endpoint, use it to POST and GET requests to the SMS endpoint
Link to this section Summary
Functions
This function makes a get request to fetch an SMS via the Africa's talking SMS endpoint, this
function accepts a map of parameters that optionally accepts lastReceivedId
of the message.
sent
Process results from calling the gateway
This function builds and runs a post request to send an SMS via the Africa's talking SMS endpoint, this
function accepts a map of parameters that should always contain the to
address and the message
to be
sent
Link to this section Types
option()
View Sourceoption() :: {:method, Tesla.Env.method()} | {:url, Tesla.Env.url()} | {:query, Tesla.Env.query()} | {:headers, Tesla.Env.headers()} | {:body, Tesla.Env.body()} | {:opts, Tesla.Env.opts()}
Link to this section Functions
This function makes a get request to fetch an SMS via the Africa's talking SMS endpoint, this
function accepts a map of parameters that optionally accepts lastReceivedId
of the message.
sent
Parameters
attrs: - an empty map or a map containing optionally lastReceivedId
of the message to be fetched, see the docs at https://build.at-labs.io/docs/sms%2Ffetch_messages for how to use these keys
Examples
iex> AtEx.Sms.fetch_sms(%{})
{:ok,
%{
"SMSMessageData" => %{
"Messages" => [
%{
"linkId" => "SampleLinkId123",
"text" => "Hello",
"to" => "28901",
"id" => 15071,
"date" => "2018-03-19T08:34:18.445Z",
"from" => "+254711XXXYYY"
}
]
}
}
}
Process results from calling the gateway
This function builds and runs a post request to send an SMS via the Africa's talking SMS endpoint, this
function accepts a map of parameters that should always contain the to
address and the message
to be
sent
Parameters
attrs: - a map containing a to
and message
key optionally it may also contain from
, bulkSMSMode
, enqueue
, keyword
, linkId
and retryDurationInHours
keys, see the docs at https://build.at-labs.io/docs/sms%2Fsending for how to use these keys
Examples
iex> AtEx.Sms.send_sms(%{to: "+254721978097", message: "Howdy"})
{:ok,
%{
"SMSMessageData" => %{
"Message" => "Sent to 1/1 Total Cost: ZAR 0.1124",
"Recipients" => [
%{
"cost" => "KES 0.8000",
"messageId" => "ATXid_a584c3fd712a00b7bce3c4b7b552ac56",
"number" => "+254721978097",
"status" => "Success",
"statusCode" => 101
}
]
}
}}