summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHentioe <me@bluerain.io>2020-10-26 04:51:58 +0800
committerHentioe <me@bluerain.io>2020-10-26 04:51:58 +0800
commit31defecc677424cfd14fe5cf5c0f8c6dec20f229 (patch)
tree37511e3c6b59d1e18d13382870897e0149ccb8fa
parentUpdate .gitignore (diff)
Fix typespecs
-rw-r--r--lib/azure_ex/request.ex6
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)