Skip to content

Commit

Permalink
Merge pull request #150 from drgmr/fix-dialyzer-errors
Browse files Browse the repository at this point in the history
Fix dialyzer errors
  • Loading branch information
danielberkompas committed Jun 5, 2021
2 parents 95e0d00 + d83fda5 commit ee0206b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
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

0 comments on commit ee0206b

Please sign in to comment.