hex_api_user (hex_core v0.7.1) View Source

HTTP API - Users.

Link to this section Summary

Functions

Creates a new user account.

Gets a user.

Gets the authenticated user.

Resets the user's password.

Link to this section Functions

Link to this function

create(Config, Username, Password, Email)

View Source

Specs

create(:hex_core.config(), binary(), binary(), binary()) :: :hex_api.response()

Creates a new user account.

Examples:

  > hex_api_user:create(hex_core:default_config(), <<"user">>, <<"hunter42">>, <<"user@example.com">>).
  {ok, {201, ..., #{
       <<"email">> => <<"user@example.com">>,
       <<"full_name">> => <<"John Doe">>,
       <<"handles">> => #{...},
       <<"inserted_at">> => <<"2014-04-21T17:20:12Z">>,
       <<"level">> => <<"full">>,
       <<"updated_at">> => <<"2019-08-04T19:28:05Z">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }}}

Specs

get(:hex_core.config(), binary()) :: :hex_api.response()

Gets a user.

Examples:

  > hex_api_user:get(hex_core:default_config()).
  {ok, {200, ..., #{
       <<"email">> => <<"user@example.com">>,
       <<"full_name">> => <<"John Doe">>,
       <<"handles">> => #{...},
       <<"inserted_at">> => <<"2014-04-21T17:20:12Z">>,
       <<"level">> => <<"full">>,
       <<"updated_at">> => <<"2019-08-04T19:28:05Z">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }}}

Specs

me(:hex_core.config()) :: :hex_api.response()

Gets the authenticated user.

Examples:

  > hex_api_user:me(hex_core:default_config()).
  {ok, {200, ..., #{
       <<"email">> => <<"user@example.com">>,
       <<"full_name">> => <<"John Doe">>,
       <<"handles">> => #{...},
       <<"inserted_at">> => <<"2014-04-21T17:20:12Z">>,
       <<"level">> => <<"full">>,
       <<"updated_at">> => <<"2019-08-04T19:28:05Z">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }}}
Link to this function

reset_password(Config, Username)

View Source

Specs

reset_password(:hex_core.config(), binary()) :: :hex_api.response()

Resets the user's password.

Examples:

  > hex_api_user:reset_password(hex_core:default_config(), <<"user">>).
  {ok, {204, ..., nil}}