Skip to content

Commit

Permalink
Merge pull request #85 from beamkenya/feature/remove-headers
Browse files Browse the repository at this point in the history
Feature/remove headers
  • Loading branch information
kamalogudah authored Aug 14, 2020
2 parents dd11ec7 + 7265484 commit b5cf361
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ end
- Add the **api key** in the `api_key:`value in the `config/dev.exs` created above.

## Example Configuration setup
Below is an example configuration for `dev.exs` this is suitable for testing with the sandbox:

``` elixir
config :at_ex,
api_key: "===INSERT AFRICAS_TALKING_API_KEY HERE ===",
content_type: "application/x-www-form-urlencoded",
accept: "application/json",
username: "sandbox", #change to live username for prod.ex
api_key: "===INSERT AFRICAS_TALKING_SANDBOX_API_KEY HERE ===",
username: "sandbox", #change to live username if you want to use the live endpoint while in development
stk_product_name: "AtEx", #Add your specific product name.
b2c_product_name: "AtEx",
b2b_product_name: "AtEx",
Expand All @@ -66,6 +66,22 @@ config :at_ex,
force_live_url: "NO"
```

Below is an example configuration for `prod.exs` this is when you go live:


``` elixir
config :at_ex,
api_key: "===INSERT AFRICAS_TALKING_LIVE_API_KEY HERE ===",
username: "LIVE_USERNAME",
stk_product_name: "AtEx", #Add your specific product name.
b2c_product_name: "AtEx",
b2b_product_name: "AtEx",
bank_checkout_product_name: "AtEx",
bank_transfer_product_name: "AtEx",
card_checkout_product_name: "AtEx"

```


## Documentation

Expand All @@ -76,7 +92,7 @@ The docs can be found at [https://hexdocs.pm/at_ex](https://hexdocs.pm/at_ex).
#### Sending SMS

```elixir
iex> AtEx.Sms.send_sms(%{to: "+254728833181", message: "Howdy"})
iex> AtEx.Sms.send_sms(%{to: "+254722000000", message: "Howdy"})
{:ok,
%{
"SMSMessageData" => %{
Expand All @@ -85,7 +101,7 @@ The docs can be found at [https://hexdocs.pm/at_ex](https://hexdocs.pm/at_ex).
%{
"cost" => "KES 0.8000",
"messageId" => "ATXid_96e52a761a82c1bad58e885109224aad",
"number" => "+254728833181",
"number" => "+254722000000",
"status" => "Success",
"statusCode" => 101
}
Expand Down
2 changes: 0 additions & 2 deletions config/dev.sample.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use Mix.Config

config :at_ex,
api_key: "===INSERT AFRICAS_TALKING_API_KEY HERE ===",
content_type: "application/x-www-form-urlencoded",
accept: "application/json",
username: "sandbox",
stk_product_name: "AtEx",
b2c_product_name: "AtEx",
Expand Down
14 changes: 14 additions & 0 deletions lib/at_ex.ex
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
defmodule AtEx do
@moduledoc """
AtEx is an Elixir Wrapper for the Africas Talking Api
Use this library to handle interaction with the Africas Talking API end points,
It is most useful for
- Consuming incoming events that have been parsed
- Building valid responses
Almost all of the endpoints have been implemented,these includes the following sections of the API:
- SMS
- USSD
- Airtime
- Application
- Voice
- Payment
- IoT
"""
alias AtEx.Gateway.{
Airtime,
Application
}

@spec send_airtime(%{recipients: [map]}) :: {:error, any} | {:ok, any}
@doc """
Sends airtime
Expand Down
4 changes: 2 additions & 2 deletions lib/at_ex/gateway/base_http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ defmodule AtEx.Gateway.Base do

@config unquote(opts)

@accept Application.get_env(:at_ex, :accept)
@accept "application/json"
@content_type "application/x-www-form-urlencoded"
@key Application.get_env(:at_ex, :api_key)
@content_type Application.get_env(:at_ex, :content_type)

plug(Tesla.Middleware.BaseUrl, @config[:url])

Expand Down

0 comments on commit b5cf361

Please sign in to comment.