Skip to content

Commit

Permalink
Change spec
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatsuba committed Dec 23, 2023
1 parent 28d40b8 commit c56ea90
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Compile
run: rebar3 compile
- name: Tests
run: |
rebar3 xref
Expand Down
12 changes: 6 additions & 6 deletions src/bellboy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@
%% @doc
%% Request to Plivo
%% @end
-spec plivo(Data :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec plivo(Data :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

plivo(Data) -> bellboy_plivo:message(Data).

%% @doc
%% Request to Twilio
%% @end
-spec twilio(Data :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec twilio(Data :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

twilio(Data) -> bellboy_twilio:message(Data).

%% @doc
%% Request to Nexmo
%% @end
-spec nexmo(Data :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec nexmo(Data :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

nexmo(Data) -> bellboy_nexmo:message(Data).
4 changes: 2 additions & 2 deletions src/bellboy_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ get_body({_, _, Body}) -> Body.
%% @doc
%% Helper for generate body: if data has JSON format - decode to map, if not - return data as result
%% @end
-spec gen_body(Data :: lists:list() | binary()) -> Result :: maps:map() | any().
-spec gen_body(Data :: list() | binary()) -> Result :: map() | any().

gen_body(Data) ->
case catch jsone:decode(Data, [{object_format, map}]) of
Expand All @@ -58,7 +58,7 @@ gen_body(Data) ->
%% @doc
%% HTTPC request with/without headers
%% @end
-spec httpc_request(Params :: maps:map()) ->
-spec httpc_request(Params :: map()) ->
{ok, Result :: tuple()} |
{error, Reason :: tuple()}.

Expand Down
20 changes: 10 additions & 10 deletions src/bellboy_nexmo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
%% @doc
%% Plivo handler
%% @end
-spec message(Data :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec message(Data :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

message(#{type := send_sms} = Data) ->
Expand All @@ -46,8 +46,8 @@ message(_) ->
%% @doc
%% Send simple SMS message
%% @end
-spec send_sms(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec send_sms(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

send_sms(#{from := F, text := TXT, to := T, api_key := AK, api_secret := AC} = B)
Expand Down Expand Up @@ -80,8 +80,8 @@ send_sms(_) ->
%% @doc
%% Send PIN SMS
%% @end
-spec send_pin(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec send_pin(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

send_pin(#{api_key := AK, api_secret := AC, number := N, brand := B, code_length := CL})
Expand Down Expand Up @@ -119,8 +119,8 @@ send_pin(_) ->
%% @doc
%% Cancel PIN SMS
%% @end
-spec cancel_pin(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec cancel_pin(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

cancel_pin(#{api_key := AK, api_secret := AC, request_id := RID}) when is_list(AK), is_list(AC), is_list(RID) ->
Expand Down Expand Up @@ -152,8 +152,8 @@ cancel_pin(_) ->
%% @doc
%% Check PIN SMS
%% @end
-spec check_pin(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec check_pin(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

check_pin(#{api_key := AK, api_secret := AC, request_id := RID, code := C})
Expand Down
16 changes: 8 additions & 8 deletions src/bellboy_plivo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
%% @doc
%% Plivo handler
%% @end
-spec message(Data :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec message(Data :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

message(#{type := send_message} = Data) ->
Expand All @@ -44,8 +44,8 @@ message(_) ->
%% @doc
%% Send simple SMS message
%% @end
-spec send_message(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec send_message(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

send_message(#{auth_id := AID, auth_token := AT} = Data)
Expand Down Expand Up @@ -77,8 +77,8 @@ send_message(_) ->
%% @doc
%% Get SMS message
%% @end
-spec get_message(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec get_message(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

get_message(#{auth_id := AID, auth_token := AT, message_uuid := MUUID})
Expand Down Expand Up @@ -108,8 +108,8 @@ get_message(_) ->
%% @doc
%% Get SMS messages
%% @end
-spec get_messages(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec get_messages(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

get_messages(#{auth_id := AID, auth_token := AT})
Expand Down
16 changes: 8 additions & 8 deletions src/bellboy_twilio.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
%% @doc
%% Twilio handler
%% @end
-spec message(Data :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec message(Data :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

message(#{type := send_message} = Data) ->
Expand All @@ -44,8 +44,8 @@ message(_) ->
%% @doc
%% Send simple SMS message
%% @end
-spec send_message(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec send_message(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

send_message(#{account_sid := AID, auth_token := AT, body := B, from := F, to := T})
Expand Down Expand Up @@ -80,8 +80,8 @@ send_message(_) ->
%% @doc
%% Get specific SMS message
%% @end
-spec get_message(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec get_message(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

get_message(#{account_sid := AID, auth_token := AT, sid := SID})
Expand Down Expand Up @@ -111,8 +111,8 @@ get_message(_) ->
%% @doc
%% Get all SMS messages
%% @end
-spec get_messages(Params :: maps:map()) ->
{ok, Result :: maps:map()} |
-spec get_messages(Params :: map()) ->
{ok, Result :: map()} |
{error, Reason :: tuple() | bad_arg}.

get_messages(#{account_sid := AID, auth_token := AT}) when is_list(AID), is_list(AT) ->
Expand Down

0 comments on commit c56ea90

Please sign in to comment.