From a4938891b7da7881a0d295e6a2569159c91f6b77 Mon Sep 17 00:00:00 2001 From: vk Date: Sat, 23 Dec 2023 15:34:16 +0200 Subject: [PATCH] Update CI and change spec --- .github/workflows/ci.yaml | 8 +++----- src/bellboy.erl | 12 ++++++------ src/bellboy_http.erl | 4 ++-- src/bellboy_nexmo.erl | 20 ++++++++++---------- src/bellboy_plivo.erl | 16 ++++++++-------- src/bellboy_twilio.erl | 16 ++++++++-------- 6 files changed, 37 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 48ff26b..d2ba7a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/src/bellboy.erl b/src/bellboy.erl index 91126d9..b36a841 100644 --- a/src/bellboy.erl +++ b/src/bellboy.erl @@ -31,8 +31,8 @@ %% @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). @@ -40,8 +40,8 @@ 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). @@ -49,8 +49,8 @@ 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). diff --git a/src/bellboy_http.erl b/src/bellboy_http.erl index 565a7db..7b8b685 100644 --- a/src/bellboy_http.erl +++ b/src/bellboy_http.erl @@ -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 @@ -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()}. diff --git a/src/bellboy_nexmo.erl b/src/bellboy_nexmo.erl index 7a27eda..1ec422a 100644 --- a/src/bellboy_nexmo.erl +++ b/src/bellboy_nexmo.erl @@ -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) -> @@ -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) @@ -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}) @@ -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) -> @@ -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}) diff --git a/src/bellboy_plivo.erl b/src/bellboy_plivo.erl index faa292a..744dc79 100644 --- a/src/bellboy_plivo.erl +++ b/src/bellboy_plivo.erl @@ -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) -> @@ -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) @@ -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}) @@ -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}) diff --git a/src/bellboy_twilio.erl b/src/bellboy_twilio.erl index 6909772..7d8aafb 100644 --- a/src/bellboy_twilio.erl +++ b/src/bellboy_twilio.erl @@ -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) -> @@ -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}) @@ -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}) @@ -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) ->