diff options
Diffstat (limited to 'lib/polyjuice/client.ex')
-rw-r--r-- | lib/polyjuice/client.ex | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/polyjuice/client.ex b/lib/polyjuice/client.ex index bdf1fde..8ab0e49 100644 --- a/lib/polyjuice/client.ex +++ b/lib/polyjuice/client.ex @@ -47,7 +47,8 @@ defmodule Polyjuice.Client do base_url: String.t(), access_token: String.t(), user_id: String.t(), - storage: Polyjuice.Client.Storage.t() + storage: Polyjuice.Client.Storage.t(), + test: boolean } @enforce_keys [:base_url] @@ -55,7 +56,8 @@ defmodule Polyjuice.Client do :base_url, :access_token, :user_id, - :storage + :storage, + test: false ] @doc "The r0 client URL prefix" @@ -114,7 +116,7 @@ defmodule Polyjuice.Client do end defimpl Polyjuice.Client.API do - def call(%{base_url: base_url, access_token: access_token}, endpoint) do + def call(%{base_url: base_url, access_token: access_token, test: test}, endpoint) do %Polyjuice.Client.Endpoint.HttpSpec{ method: method, headers: headers, @@ -129,7 +131,9 @@ defmodule Polyjuice.Client do {:error, :auth_required} else case :hackney.request( - method, + # mod_esi doesn't like POST requests to a sub-path, so change POST + # to PUT when running tests + if(method == :post and test, do: :put, else: method), url, if access_token do [{"Authorization", "Bearer #{access_token}"} | headers] |