From 855a481b72d042f4cfff34a964e7ac447da24daa Mon Sep 17 00:00:00 2001 From: Paul Oguda Date: Mon, 10 Aug 2020 01:27:35 +0300 Subject: [PATCH 1/3] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 1df2a98..2b79ff5 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,17 @@ If you don't see your idea listed, [Open an issue](https://github.com/beamkenya/ Check the [Contribution guide](contributing.md) on how to contribute. +## Maintainers +The current maintainers of the project are: +1. [Tracey Onim](https://github.com/TraceyOnim) +2. [Manuel Magak](https://github.com/manuelgeek) +3. [Paul Oguda](https://github.com/kamalogudah) +4. [Sigu Magwa](https://github.com/sigu) + +## Past Maintainers +1. [Zacck Osiemo](https://github.com/zacck) Thanks for kicking off the project :wink:. + + ## Licence AtEx is released under [MIT License](https://github.com/appcues/exsentry/blob/master/LICENSE.txt) From ae34ee5b4cb331ba25bff9c6c230096d4d24ab72 Mon Sep 17 00:00:00 2001 From: kamalogudah Date: Fri, 14 Aug 2020 18:45:09 +0300 Subject: [PATCH 2/3] Adds documentation for installation --- README.md | 28 ++++++++++++++++++++++------ config/dev.sample.exs | 2 -- lib/at_ex.ex | 31 +++++++++++++++++++++++++++++++ lib/at_ex/gateway/base_http.ex | 4 ++-- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7d35dfc..07b1fd4 100644 --- a/README.md +++ b/README.md @@ -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", @@ -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 @@ -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" => %{ @@ -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 } diff --git a/config/dev.sample.exs b/config/dev.sample.exs index 9d9052b..e8455ed 100644 --- a/config/dev.sample.exs +++ b/config/dev.sample.exs @@ -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", diff --git a/lib/at_ex.ex b/lib/at_ex.ex index 1113ddf..9daa55a 100644 --- a/lib/at_ex.ex +++ b/lib/at_ex.ex @@ -1,12 +1,43 @@ 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 + + ## Getting Started and Installation + To set up first of all you need to add a `config: at_ex` in either your `config/prod.exs` for when you are going live + and `config/dev.exs` for testing in the sandbox. + The `config: at_ex`should be as below: + + ## Example Config + config/dev.exs + `config :at_ex, + api_key: "YOURSANDBOXAPIKEY", + username: "YOURSANDBOXUSERNAME" + ` + config/prod.exs + `config :at_ex, + api_key: "YOURLIVEAPIKEY", + username: "YOURLIVEUSERNAME" + ` """ alias AtEx.Gateway.{ Airtime, Application } + @spec send_airtime(%{recipients: [map]}) :: {:error, any} | {:ok, any} @doc """ Sends airtime diff --git a/lib/at_ex/gateway/base_http.ex b/lib/at_ex/gateway/base_http.ex index cec316b..c894acf 100644 --- a/lib/at_ex/gateway/base_http.ex +++ b/lib/at_ex/gateway/base_http.ex @@ -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]) From 72654840ebeecc76eb34cf5edeb84f80579d54a7 Mon Sep 17 00:00:00 2001 From: kamalogudah Date: Sat, 15 Aug 2020 00:45:57 +0300 Subject: [PATCH 3/3] Remove repeatition --- lib/at_ex.ex | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/at_ex.ex b/lib/at_ex.ex index 9daa55a..ac73be6 100644 --- a/lib/at_ex.ex +++ b/lib/at_ex.ex @@ -14,23 +14,6 @@ defmodule AtEx do - Voice - Payment - IoT - - ## Getting Started and Installation - To set up first of all you need to add a `config: at_ex` in either your `config/prod.exs` for when you are going live - and `config/dev.exs` for testing in the sandbox. - The `config: at_ex`should be as below: - - ## Example Config - config/dev.exs - `config :at_ex, - api_key: "YOURSANDBOXAPIKEY", - username: "YOURSANDBOXUSERNAME" - ` - config/prod.exs - `config :at_ex, - api_key: "YOURLIVEAPIKEY", - username: "YOURLIVEUSERNAME" - ` """ alias AtEx.Gateway.{ Airtime,