diff options
Diffstat (limited to 'lib/polyjuice/client/account.ex')
-rw-r--r-- | lib/polyjuice/client/account.ex | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/polyjuice/client/account.ex b/lib/polyjuice/client/account.ex index d7b8d0d..cd99f01 100644 --- a/lib/polyjuice/client/account.ex +++ b/lib/polyjuice/client/account.ex @@ -18,16 +18,19 @@ defmodule Polyjuice.Client.Account do """ @doc """ - Get the data on an account - `event_type` : type of event queried - `user_id`: User concerned by the event + Get the data on an account. + + `user_id` is the user whose data is to be queried; if not specified, defaults + to the user represented by `client_api`. `event_type` is the type of event + queried. """ @spec get_data( client_api :: Polyjuice.Client.API.t(), user_id :: String.t() | nil, event_type :: String.t() ) :: {:ok, map()} | any - def get_data(client_api, user_id \\ nil, event_type) do + def get_data(client_api, user_id \\ nil, event_type) + when (is_binary(user_id) or user_id == nil) and is_binary(event_type) do Polyjuice.Client.API.call( client_api, %Polyjuice.Client.Endpoint.GetAccountData{ @@ -38,24 +41,26 @@ defmodule Polyjuice.Client.Account do end @doc """ - Put the data on an account - `event_type` : type of event requiring modifications - `changes`: New changes - `user_id`: User concerned by the event + Put the data on an account. + + `user_id` is the user whose data is to be set; if not specified, defaults to + the user represented by `client_api`. `event_type` is type of event to set and + `data` is the new data. """ @spec put_data( client_api :: Polyjuice.Client.API.t(), user_id :: String.t() | nil, event_type :: String.t(), - changes :: Map.t() + data :: Map.t() ) :: {:ok} | any - def put_data(client_api, user_id \\ nil, event_type, changes) do + def put_data(client_api, user_id \\ nil, event_type, data) + when (is_binary(user_id) or user_id == nil) and is_binary(event_type) and is_map(data) do Polyjuice.Client.API.call( client_api, %Polyjuice.Client.Endpoint.PutAccountData{ user_id: user_id || Polyjuice.Client.API.get_user_and_device(client_api) |> elem(0), type: event_type, - account_data: changes + account_data: data } ) end |