AtEx v0.20.22 AtEx.Gateway.Sms.PremiumSubscriptions View Source
This module holds the implementation for the HTTP Gateway that runs calls against the Africas Talking API Premium SMS endpoint, complete a premium sms create subscription request, incrementally fetch your premium sms subscriptions, delete a premium sms subscription
Link to this section Summary
Functions
This function makes a post request to subscribe to premium sms content via the Africa's talking subscription endpoint, this function accepts an map of parameters. sent
This function makes a POST request to delete sms subscriptions via the Africa's talking subscription endpoint, this function accepts an map of parameters
This function makes a GET request to fetch premium sms subscriptions via the Africa's talking subscription endpoint, this function accepts an map of parameters. sent
This function fetches the checkout token from the checkout token endpoint THIS IS DIFFERENT THAN THE SMS ENDPOINT!!
Process results from calling the gateway
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 post request to subscribe to premium sms content via the Africa's talking subscription endpoint, this function accepts an map of parameters. sent
Config
Add shortcode
, and keyword
to the AtEx configs
Parameters
attrs: - a map containing:
phoneNumber
- phone number to be subscribed Check https://build.at-labs.io/docs/sms%2Fpremium_subscriptions%2Fcreate
Example
iex> AtEx.Gateway.Sms.PremiumSubscriptions.create_subscription(%{phoneNumber: "+25471231111"})
{:ok,
%{
"SMSMessageData" => %{"Message" => "Sent to 1/1 Total Cost: ZAR 0.1124", "Recipients" => [%{"cost" => "KES 0.8000", "messageId" => "ATXid_a584c3fd712a00b7bce3c4b7b552ac56", "number" => "+254728833181", "status" => "Success", "statusCode" => 101}]}
}}
This function makes a POST request to delete sms subscriptions via the Africa's talking subscription endpoint, this function accepts an map of parameters:
Parameters
attrs: - a map containing:
shortCode
- premium short code mapped to your accountkeyword
- premium keyword under the above short code mapped to your accountphoneNumber
- phone number to be unsubscribed
Example
iex> AtEx.Gateway.Sms.PremiumSubscriptions.delete_subscription(%{ phoneNumber: "+25471231111"})
{:ok, %{"description" => "Succeeded", "status" => "Success"}}
This function makes a GET request to fetch premium sms subscriptions via the Africa's talking subscription endpoint, this function accepts an map of parameters. sent
Parameters
attrs: - a map containing:
shortCode
- premium short code mapped to your accountkeyword
- premium keyword under the above short code mapped to your accountlastReceivedId
- (optional) ID of the subscription you believe to be your last. Set it to 0 to for the first time. For more info, look at the docs here https://build.at-labs.io/docs/sms%2Fpremium_subscriptions%2Ffetch
Example
iex> AtEx.Gateway.Sms.PremiumSubscriptions.fetch_subscriptions()
{:ok,
%{
"SMSMessageData" => %{
"Messages" => [
%{
"linkId" => "SampleLinkId123",
"text" => "Hello",
"to" => "28901",
"id" => 15071,
"date" => "2018-03-19T08:34:18.445Z",
"from" => "+254711XXXYYY"
}
]
}
}}
This function fetches the checkout token from the checkout token endpoint THIS IS DIFFERENT THAN THE SMS ENDPOINT!!
phone_number: - a string representing a valid phone number in EL64
(+
Returns a success tuple: {:ok,
Process results from calling the gateway