diff options
author | Hentioe <me@bluerain.io> | 2020-10-26 04:51:58 +0800 |
---|---|---|
committer | Hentioe <me@bluerain.io> | 2020-10-26 04:51:58 +0800 |
commit | 31defecc677424cfd14fe5cf5c0f8c6dec20f229 (patch) | |
tree | 37511e3c6b59d1e18d13382870897e0149ccb8fa /lib | |
parent | Update .gitignore (diff) |
Fix typespecs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/azure_ex/request.ex | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/azure_ex/request.ex b/lib/azure_ex/request.ex index 616d1d7..836f9fa 100644 --- a/lib/azure_ex/request.ex +++ b/lib/azure_ex/request.ex @@ -16,18 +16,20 @@ defmodule AzureEx.Request do @type params :: %{query_params: keyword | map, body: keyword | map} @type result :: any @type error :: any + @type httpoison_result :: {:ok, HTTPoison.Response.t()} | {:error, HTTPoison.Error.t()} @spec call(binary, atom, params) :: - {:ok, HTTPoison.Response.t()} | {:error, HTTPoison.Error.t()} + {:ok, result} | {:error, error} def call(api, method, params \\ %{query_params: %{}, body: %{}}) do method |> send(endpoint(api), params) |> handle_response() end - @spec handle_response({:ok, HTTPosion.Response.t()}) :: {:ok, result} | {:error, error} + @spec handle_response({:ok, HTTPoison.Response.t()}) :: {:ok, result} | {:error, error} def handle_response({:ok, %HTTPoison.Response{body: body}}) do body |> Jason.decode!(keys: :atoms) end + @spec send(:get, String.t(), params) :: httpoison_result def send(:get, endpoint, %{query_params: query_params}) do endpoint = endpoint <> to_query(query_params) |