bellboy - is Erlang
HTTP
client library for send SMS by different services: Plivo, Twilio, Nexmo.
- Goals
- Build & Run
- Dialyzer
- Clean Project
- Install bellboy to project
- Erlang Plivo
- Erlang Twilio
- Erlang Nexmo
- Support
Bellboy aims to provide a simple way for send SMS by different services by REST API.
$ git clone https://github.com/vkatsuba/bellboy.git
$ cd bellboy
$ wget https://s3.amazonaws.com/rebar3/rebar3
$ chmod u+x ./rebar3
$ ./rebar3 shell
$ ./rebar3 dialyzer
$ ./rebar3 clean
Install bellboy to project: Rebar3
- Edit file rebar.config:
{deps, [
{bellboy, "2.0.0"},
]}.
% 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).
% 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).
% 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).
% 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).
% 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).
% 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).
% 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).
% 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).
% 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).
% 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).