Packages

Inofficial Erlang/OTP client application for the official DeepL API Version 2

Current section

Files

Jump to
deeperl src deeperl_usage.erl
Raw

src/deeperl_usage.erl

%%% @private
-module(deeperl_usage).
-behavior(gen_deeperl_procedure).
%% API
-export([uri/0, body/1, response/1]).
-spec uri() -> nonempty_string().
uri() ->
"/v2/usage".
-spec body(Args :: tuple()) -> iodata().
body(_) ->
[].
-spec response(Data :: map()) -> deeperl:usage_result().
response(#{<<"character_count">> := CharacterCount, <<"character_limit">> := CharacterLimit}) when is_integer(CharacterCount), is_integer(CharacterLimit)->
{CharacterCount, CharacterLimit};
response(_) ->
{error, invalid_response}.