summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Chathi <hubert@uhoreg.ca>2021-01-06 14:57:16 +0000
committerHubert Chathi <hubert@uhoreg.ca>2021-01-06 14:57:16 +0000
commit6e4924b8973394d70df5115721b2bca7579af952 (patch)
treefc6d59b4358c242122b647d68e8c486a35161650
parentdoc and other minor fixes (diff)
parentallow setting user_id in Client.LowLevel API (diff)
Merge branch 'user_impersonation' into 'master'
allow setting user_id in Client.LowLevel API See merge request uhoreg/polyjuice_client!6
-rw-r--r--lib/polyjuice/client/low_level.ex17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/polyjuice/client/low_level.ex b/lib/polyjuice/client/low_level.ex
index 91b39ae..6a6521d 100644
--- a/lib/polyjuice/client/low_level.ex
+++ b/lib/polyjuice/client/low_level.ex
@@ -37,6 +37,7 @@ defmodule Polyjuice.Client.LowLevel do
user_id: String.t(),
device_id: String.t(),
storage: Polyjuice.Client.Storage.t(),
+ application_service: boolean,
test: boolean
}
@@ -47,11 +48,21 @@ defmodule Polyjuice.Client.LowLevel do
:user_id,
:device_id,
:storage,
+ application_service: false,
test: false
]
defimpl Polyjuice.Client.API do
- def call(%{base_url: base_url, access_token: access_token, test: test}, endpoint) do
+ def call(
+ %{
+ base_url: base_url,
+ access_token: access_token,
+ user_id: user_id,
+ application_service: application_service,
+ test: test
+ },
+ endpoint
+ ) do
%Polyjuice.Client.Endpoint.HttpSpec{
method: method,
headers: headers,
@@ -62,6 +73,10 @@ defmodule Polyjuice.Client.LowLevel do
stream_response: stream_response
} = Polyjuice.Client.Endpoint.Proto.http_spec(endpoint)
+ query = query || []
+
+ query = if application_service, do: [{:user_id, user_id} | query], else: query
+
url =
%{
URI.merge(base_url, path)