Skip to content

📧 Bellboy - is HTTP client library for send SMS by different services: Plivo, Twilio, Nexmo

License

Notifications You must be signed in to change notification settings

vkatsuba/bellboy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bellboy

bellboy - is Erlang HTTP client library for send SMS by different services: Plivo, Twilio, Nexmo.

Hex.pm Version

Build Status

Contents

Goals

Bellboy aims to provide a simple way for send SMS by different services by REST API.

Build & Run

$ git clone https://github.com/vkatsuba/bellboy.git
$ cd bellboy
$ wget https://s3.amazonaws.com/rebar3/rebar3
$ chmod u+x ./rebar3
$ ./rebar3 shell

Dialyzer

$ ./rebar3 dialyzer

Clean Project

$ ./rebar3 clean

Install bellboy to project: Rebar3

  • Edit file rebar.config:
{deps, [
    {bellboy, "2.0.0"},
]}.

Erlang Plivo

Send SMS By Erlang Plivo

% https://docs.labs.plivo.com/latest/python/elements/message/send-an-sms
ReqMap = #{
   type => send_message,            % atom()   - bellboy type for send SMS
   auth_id => "PlivoAuthID",        % list()   - Plivo auth ID
   auth_token => "PlivoAuthToken",  % list()   - Plivo auth token
   src => <<"00000000000000000">>,  % binary() - Plivo phone number
   dst => <<"11111111111111111">>,  % binary() - user phone number
   text => <<"Plivo SMS Text">>     % binary() - SMS text
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:plivo(ReqMap).

Get Details of a Single Message By Erlang Plivo

% https://www.plivo.com/docs/sms/getting-started/advanced/sms-details-single-message
ReqMap = #{
   type => get_message,             % atom() - bellboy type for send SMS
   auth_id => "PlivoAuthID",        % list() - Plivo auth ID
   auth_token => "PlivoAuthToken",  % list() - Plivo auth token
   message_uuid => "PlivoMsgUUID"   % list() - Plivo message UUID
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:plivo(ReqMap).

Get Details of all Messages By Erlang Plivo

% https://www.plivo.com/docs/sms/getting-started/advanced/sms-details-all-messages/
ReqMap = #{
   type => get_messages,            % atom() - bellboy type for send SMS
   auth_id => "PlivoAuthID",        % list() - Plivo auth ID
   auth_token => "PlivoAuthToken"   % list() - Plivo auth token
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:plivo(ReqMap).

Erlang Twilio

Send SMS By Erlang Twilio

% https://www.twilio.com/docs/sms/send-messages
ReqMap = #{
   type        => send_message,         % atom() - bellboy type for send SMS
   account_sid => "TwilioAccountSID",   % list() - Twilio account SID
   auth_token  => "TwilioAuthToken",    % list() - Twilio auth token
   body        => "Twilio SMS Text",    % list() - SMS text
   from        => "00000000000000000",  % list() - Twilio phone number
   to          => "11111111111111111"   % list() - User phone number
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:twilio(ReqMap).

Fetch a Message Resource By Erlang Twilio

% https://www.twilio.com/docs/sms/api/message-resource#fetch-a-message-resource
ReqMap = #{
   type        => get_message,          % atom() - bellboy type for send SMS
   account_sid => "TwilioAccountSID",   % list() - Twilio account SID
   auth_token  => "TwilioAuthToken",    % list() - Twilio auth token
   sid         => "MsgSid"              % list() - Twilio SID of SMS message
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:twilio(ReqMap).

Read Multiple Message Resources By Erlang Twilio

% https://www.twilio.com/docs/sms/api/message-resource#read-multiple-message-resources
ReqMap = #{
   type        => get_messages,         % atom() - bellboy type for send SMS
   account_sid => "TwilioAccountSID",   % list() - Twilio account SID
   auth_token  => "TwilioAuthToken"     % list() - Twilio auth token
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:twilio(ReqMap).

Erlang Nexmo

Send SMS By Erlang Nexmo

% https://developer.nexmo.com/api/sms
ReqMap = #{
   type        => send_sms,                 % atom()   - bellboy type for send SMS
   from        => <<"00000000000000000">>,  % binary() - Nexmo name or number
   to          => <<"11111111111111111">>,  % binary() - User phone number
   text        => <<"Nexmo SMS text">>,     % binary() - SMS text
   api_key     => <<"ApiKey">>,             % binary() - Nexmo API key
   api_secret  => <<"ApiSecret">>           % binary() - Nexmo API secret
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:nexmo(ReqMap).

Send PIN By Erlang Nexmo

% https://developer.nexmo.com/verify/overview 
ReqMap = #{
   type        => send_pin,             % atom() - bellboy type for send SMS
   brand       => "Brand",              % list() - Nexmo brand
   number      => "11111111111111111",  % list() - User phone number
   code_length => "4",                  % list() - Length of PIN
   api_key     => "ApiKey",             % list() - Nexmo API key
   api_secret  => "ApiSecret"           % list() - Nexmo API secret
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:nexmo(ReqMap).

Check PIN By Erlang Nexmo

% https://developer.nexmo.com/verify/overview 
ReqMap = #{
   type        => check_pin,   % atom() - bellboy type for send SMS
   request_id  => "ReqID",     % list() - Nexmo `request_id` field from `send_pin` response
   code        => "1111",      % list() - Nexmo PIN code 
   api_key     => "ApiKey",    % list() - Nexmo API key
   api_secret  => "ApiSecret"  % list() - Nexmo API secret
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:nexmo(ReqMap).

Cancel PIN By Erlang Nexmo

% https://developer.nexmo.com/verify/overview 
ReqMap = #{
   type        => cancel_pin,  % atom() - bellboy type for send SMS
   request_id  => "ReqID",     % list() - Nexmo `request_id` field from `send_pin` response
   api_key     => "ApiKey",    % list() - Nexmo API key
   api_secret  => "ApiSecret"  % list() - Nexmo API secret
},

% Code     - integer()
% Body     - map() | list()
% Response - list()
{ok, #{code := Code, body := Body, response := FullResp}} = bellboy:nexmo(ReqMap).

Support

v.katsuba.dev@gmail.com