diff options
Diffstat (limited to 'src/r3_hex_api_user.erl')
| -rw-r--r-- | src/r3_hex_api_user.erl | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/r3_hex_api_user.erl b/src/r3_hex_api_user.erl new file mode 100644 index 0000000..67d32ce --- /dev/null +++ b/src/r3_hex_api_user.erl @@ -0,0 +1,46 @@ +%% Vendored from hex_core v0.5.0, do not edit manually + +-module(r3_hex_api_user). +-export([ + create/4, + get/2, + me/1, + reset_password/2 +]). + +me(Config) when is_map(Config) -> + r3_hex_api:get(Config, ["users", "me"]). + +create(Config, Username, Password, Email) -> + Params = #{ + <<"username">> => Username, + <<"password">> => Password, + <<"email">> => Email + }, + r3_hex_api:post(Config, ["users"], Params). + +reset_password(Username, Config) when is_binary(Username) and is_map(Config) -> + r3_hex_api:post(Config, ["users", Username, "reset"], #{}). + +%% @doc +%% Gets user. +%% +%% Examples: +%% +%% ``` +%% > r3_hex_api_user:get(<<"user">>, r3_hex_core:default_config()). +%% {ok, {200, ..., #{ +%% <<"username">> => <<"user">>, +%% <<"packages">> => [ +%% #{ +%% <<"name">> => ..., +%% <<"url">> => ..., +%% ... +%% }, +%% ... +%% ], +%% ...}}} +%% ''' +%% @end +get(Config, Username) when is_binary(Username) and is_map(Config) -> + r3_hex_api:get(Config, ["users", Username]). |
