Skip to content

Commit

Permalink
Update CI and change spec
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatsuba committed Dec 23, 2023
1 parent 5a9d627 commit a493889
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 39 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
otp: [21.3, 22.0.7, 22.3, 23.0.4, 23.2.7.0, 24.0]
otp: [21, 22, 23, 24, 25, 26]
container:
image: erlang:${{ matrix.otp }}-alpine
image: erlang:${{ matrix.otp }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Compile
run: rebar3 compile
uses: actions/checkout@v4
- 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 a493889

Please sign in to comment.