Giter VIP home page Giter VIP logo

sms_blitz's Introduction

SmsBlitz

Build Status

SmsBlitz is a library for elixir that allows you to send SMS messages through multiple different providers.

SmsBlitz provides a generic behaviour to make it easy to write conforming client libraries, while also making it simple for developers to choose which provider to use (you could use ex_phone_number to detect the destination country and use the cheapest provider for that country, for example).

Installation

If available in Hex, the package can be installed as:

  1. Add sms_blitz to your list of dependencies in mix.exs:
        def deps do
          [{:sms_blitz, "~> 0.1.1"}]
        end
  1. Ensure sms_blitz is started before your application:
        def application do
          [applications: [:sms_blitz]]
        end

Setup

Setting up with SmsBlitz is easy. You simply add the authentication details for the providers you want to use into to your config:

config :sms_blitz, plivo: {"api_token", "api_key"}
config :sms_blitz, itagg: {"username", "password", "route"}
config :sms_blitz, twilio: {"account_sid", "auth_token"}
config :sms_blitz, nexmo: {"account_key", "account_secret"}

You can find out which adapters are available like so (note that the list of adapters is not the same as the list of adapters which has been configured correctly!):

SmsBlitz.adapters
# [:plivo, :itagg, :twilio, :nexmo]

Then you can send the SMS to the provider as simply as this:

SmsBlitz.send_sms(:adapter, from: "Johnny", to: "07123456789", message: "Here's Johnny!")

Where :adapter is the adapter you've chosen from the list.

The output of the send_sms/2 command above will either be like:

%{
  id: "id here",
  result_string: "Things went well",
  status_code: "1337"
}

Or an Array of maps formatted as above. It's important that you handle both types of responses!

sms_blitz's People

Contributors

bigkevmcd avatar iamd3vil avatar johnhamelink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

sms_blitz's Issues

allow using custom adapters

Right now they are hardcoded in a map, it seems. I want be able to add new adapters by providing a module which implements the sms_blitz.adapter behaviour.

What I want to do is:

SmsBlitz.send_sms(MyApp.SMS.LocalAdapter, sms_params) # -> Logger.debug(... sms_params ...)
SmsBlitz.send_sms(MyApp.SMS.TestAdapter, sms_params) # -> send(test_pid, {:sms, sms_params})

test adapter?

๐Ÿ‘‹

If you are open to it, I can make a PR which would add a test adapter akin to bamboo's one, which would send messages like {:sms, sms_params} to either the current process or some other registered process.

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.