diff options
Diffstat (limited to 'lib/polyjuice/client.ex')
-rw-r--r-- | lib/polyjuice/client.ex | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/polyjuice/client.ex b/lib/polyjuice/client.ex index d7ad60a..361914d 100644 --- a/lib/polyjuice/client.ex +++ b/lib/polyjuice/client.ex @@ -309,6 +309,11 @@ defmodule Polyjuice.Client do end @impl GenServer + def handle_call(:get_user_and_device, _from, state) do + {:reply, {Map.get(state, :user_id), Map.get(state, :device_id)}, state} + end + + @impl GenServer def handle_cast({:set, new_state}, state) do Map.take(new_state, [:access_token, :user_id, :device_id]) |> (&Map.merge(state, &1)).() @@ -366,6 +371,13 @@ defmodule Polyjuice.Client do def transaction_id(client_api) @doc """ + Get the client's user and device IDs. + """ + @spec get_user_and_device(client_api :: Polyjuice.Client.API.t()) :: + {String.t() | nil, String.t() | nil} + def get_user_and_device(client_api) + + @doc """ Stop the client. """ @spec stop(Polyjuice.Client.t(), reason :: term, timeout()) :: :ok @@ -502,6 +514,10 @@ defmodule Polyjuice.Client do "#{Node.self()}_#{:erlang.system_time(:millisecond)}_#{:erlang.unique_integer()}" end + def get_user_and_device(%{pid: pid}) do + GenServer.call(pid, :get_user_and_device) + end + def stop(%{pid: pid}, reason \\ :normal, timeout \\ :infinity) do GenServer.stop(pid, reason, timeout) end |