From 31defecc677424cfd14fe5cf5c0f8c6dec20f229 Mon Sep 17 00:00:00 2001 From: Hentioe Date: Mon, 26 Oct 2020 04:51:58 +0800 Subject: Fix typespecs --- lib/azure_ex/request.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') 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) -- cgit v1.2.3