Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dialyzer errors #150

Merged
merged 2 commits into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ MIX_ENV=test mix format --check-formatted || { echo 'Please format code with `mi

MIX_ENV=test mix compile --warnings-as-errors --force || { echo 'Please fix all compiler warnings.'; exit 1; }

MIX_ENV=test mix dialyze || { echo 'Please fix all dialyzer errors.'; exit 1; }

MIX_ENV=test mix docs || { echo 'Elixir HTML docs were not generated!'; exit 1; }

mix test || { echo 'Elixir tests failed!'; exit 1; }
Expand Down
33 changes: 15 additions & 18 deletions lib/ex_twilio/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ defmodule ExTwilio.Api do
Items are returned as instances of the given module's struct. For more
details, see the documentation for each function.
"""

use HTTPoison.Base

alias ExTwilio.Config
Expand Down Expand Up @@ -170,14 +169,25 @@ defmodule ExTwilio.Api do

def auth_header(headers, _), do: headers

@spec format_data(any) :: binary
def format_data(data)

def format_data(data) when is_map(data) do
data
|> Map.to_list()
|> Url.to_query_string()
end

def format_data(data) when is_list(data) do
Url.to_query_string(data)
end

def format_data(data), do: data

###
# HTTPotion API
###

@doc """
Automatically adds the correct headers to each API request.
"""
@spec process_request_headers(list) :: list
def process_request_headers(headers \\ []) do
headers
|> Keyword.put(:"Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
Expand All @@ -187,17 +197,4 @@ defmodule ExTwilio.Api do
def process_request_options(options) do
Keyword.merge(options, Config.request_options())
end

@spec format_data(data) :: binary
def format_data(data) when is_map(data) do
data
|> Map.to_list()
|> Url.to_query_string()
end

def format_data(data) when is_list(data) do
Url.to_query_string(data)
end

def format_data(data), do: data
end
2 changes: 1 addition & 1 deletion lib/ex_twilio/jwt/access_token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ defmodule ExTwilio.JWT.AccessToken do
"cty" => "twilio-fpa;v=1"
})

Joken.generate_and_sign!(token_config, nil, signer)
Joken.generate_and_sign!(token_config, %{}, signer)
end

defp list_of_grants?(grants) when is_list(grants) do
Expand Down
3 changes: 2 additions & 1 deletion lib/ex_twilio/url_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ defmodule ExTwilio.UrlGenerator do
end

@spec add_account_to_options(atom, list) :: list
defp add_account_to_options(module, options)

defp add_account_to_options(module, options) do
if module == ExTwilio.Account and options[:account] == nil do
options
Expand All @@ -155,7 +157,6 @@ defmodule ExTwilio.UrlGenerator do
end
end

@spec add_account_to_options(atom, list) :: list
defp add_flow_to_options(_module, options) do
Keyword.put_new(options, :flow, Keyword.get(options, :flow_sid))
end
Expand Down