Code Monkey home page Code Monkey logo

phxtestbed's Introduction

Phoenix TestBed

This is a Application to show how to use various Phoenix packages from My Packages and the Elixir Kenya community

Configutation

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.setup
  • Install Node.js dependencies with cd assets && npm install
  • Start Phoenix endpoint with mix phx.server

Now you can visit localhost:4000 from your browser.

Included packages

  1. PhxIzitoast
  2. AtEx - Africastalking
    • SMS
    • USSD
  3. Mpesa Elixir

Packages

This is a Phoenix Elixir IziToast Notification wrapper. https://izitoast.marcelodolza.com, A JavaScript Notifications Toast Library.

Package documentation

Usage

Navigate to localhost to view the toasts Code sample found at /controllers/page_controller.ex

  def index(conn, _params) do
    conn
    |> PhxIzitoast.success("Success", "This is a Success message", position: "center")
    |> PhxIzitoast.warning("Warning", "This is a warning Message", position: "bottomRight")
    |> PhxIzitoast.error("Error", "This is an Error", position: "bottomLeft")
    |> PhxIzitoast.info("Notice", "This is a Notice", position: "topRight")
    |> PhxIzitoast.message("I am a  Message, Peace")
    |> render("index.html")
  end

An API Wrapper for the Africas Talking API The wrapper is still under dev,

Contribute

SMS

Sending SMS

iex> AtEx.send_sms(%{to: "+254724540039",     message: "Yes Bana"})
{:ok,
        %{
          "SMSMessageData" => %{
          "Message" => "Sent to 1/1 Total Cost: ZAR 0.1124",
          "Recipients" => [
          %{
           "cost" => "KES 0.8000",
           "messageId" => "ATXid_96e52a761a82c1bad58e885109224aad",
           "number" => "+254724540039",
           "status" => "Success",
           "statusCode" => 101
          }
          ]
        }
      }}

USSD

To generate the response, you can use the function AtEx.USSD.build_response/1 or AtEx.USSD.build_response/2.

 iex> AtEx.USSD.build_response("What do you want to order", ["Chips & Sausage", "Burger & Chips", "Rice & beans"])
{:ok, "CON What do you want to order\n1. Chips & Sausage\n2. Burger & Chips\n3. Rice & beans" }

Look at /controllers/api/ussd_controller.ex for a sample USSD app link


This is wrapper for Daraja Mpesa STK implementation(Lipa na Mpesa Online)

Online Documentation

Usage

    iex> Mpesa.make_request(10, "254724540039", "reference", "description")
      {:ok,
        %{
        "CheckoutRequestID" => "ws_CO_010320202011179845",
        "CustomerMessage" => "Success. Request accepted for processing",
        "MerchantRequestID" => "25558-10595705-4",
        "ResponseCode" => "0",
        "ResponseDescription" => "Success. Request accepted for processing"
        }}

        {:error, "Invalid Access Token"}

About Me

Magak Emmanuel


License

license

Open Source Love

Happy coding, Star before Fork ๐Ÿ˜Š๐Ÿ’ช๐Ÿ’ฏ


Learn more

phxtestbed's People

Contributors

manuelgeek avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.