View Source hex_api_organization_member (hex_core v0.10.3)

Hex HTTP API - Organization Members.

Summary

Functions

Adds an organization member.

Deletes an organization member.

Gets an organization member.

Lists the organization's members.

Updates an organization member's role.

Types

role/0

-type role() :: admin | write | read.

Functions

add(Config, UsernameOrEmail, Role)

-spec add(hex_core:config(), binary(), role()) -> hex_api:response().

Adds an organization member.

Examples:

  > hex_api_organization_member:add(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>, write).
  {ok, {200, ..., #{
       <<"email">> => <<"user@example.com">>,
       <<"role">> => <<"write">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }}}

delete(Config, UsernameOrEmail)

-spec delete(hex_core:config(), binary()) -> hex_api:response().

Deletes an organization member.

Examples:

  > hex_api_organization_member:delete(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>).
  {ok, {204, ..., nil}}

get(Config, UsernameOrEmail)

-spec get(hex_core:config(), binary()) -> hex_api:response().

Gets an organization member.

Examples:

  > hex_api_organization_member:get(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>).
  {ok, {200, ..., #{
       <<"email">> => <<"user@example.com">>,
       <<"role">> => <<"admin">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }}}

list(Config)

-spec list(hex_core:config()) -> hex_api:response().

Lists the organization's members.

Examples:

  > hex_api_organization_member:list(hex_core:default_config(), #{api_organization => <<"acme">>}).
  {ok, {200, ..., [#{
       <<"email">> => <<"user@example.com">>,
       <<"role">> => <<"admin">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }]}}

update(Config, UsernameOrEmail, Role)

-spec update(hex_core:config(), binary(), role()) -> hex_api:response().

Updates an organization member's role.

Examples:

  > hex_api_organization_member:update(hex_core:default_config(), #{api_organization => <<"acme">>}, <<"user">>, read).
  {ok, {200, ..., #{
       <<"email">> => <<"user@example.com">>,
       <<"role">> => <<"read">>,
       <<"url">> => <<"https://hex.pm/api/users/user">>,
       <<"username">> => <<"user">>
       }}}