Ramp.Users (ramp v1.0.0)

Copy Markdown View Source

The Users resource: inviting, listing, updating, deactivating, and reactivating Ramp platform users.

Like Ramp.Cards, user creation is asynchronous -- create/2 polls to completion by default (poll: false to opt out).

Summary

Functions

Invites a new Ramp user. The user starts in "INVITE_PENDING" status until they accept the email invitation.

Deactivates a user and cancels their associated cards.

Fetches a single user by ID.

Returns a lazily auto-paginating Stream of Ramp.Users.Users.

Fetches a single page of users. See Ramp.Page.

Restores a previously deactivated user.

Updates a user's mutable fields.

Types

create_opt()

@type create_opt() ::
  {:department_id, String.t()}
  | {:location_id, String.t()}
  | {:manager_id, String.t()}
  | {:direct_manager_id, String.t()}
  | {:phone, String.t()}
  | {:employee_id, String.t()}
  | {:poll, boolean()}
  | {:poll_timeout_ms, pos_integer()}

list_opt()

@type list_opt() ::
  {:start, String.t()}
  | {:page_size, pos_integer()}
  | {:department_id, String.t()}
  | {:location_id, String.t()}
  | {:updated_after, DateTime.t()}

update_opt()

@type update_opt() ::
  {:first_name, String.t()}
  | {:last_name, String.t()}
  | {:role, String.t()}
  | {:department_id, String.t()}
  | {:location_id, String.t()}
  | {:manager_id, String.t()}
  | {:direct_manager_id, String.t()}
  | {:phone, String.t()}
  | {:employee_id, String.t()}

Functions

create(client, params, opts \\ [])

@spec create(Ramp.Client.t(), map(), [create_opt()]) ::
  {:ok, Ramp.Users.User.t()}
  | {:ok, Ramp.DeferredTaskRef.t()}
  | {:error, Ramp.Error.t()}

Invites a new Ramp user. The user starts in "INVITE_PENDING" status until they accept the email invitation.

Required: email, first_name, last_name, role (one of "ADMIN", "CARDHOLDER", "BUSINESS_OWNER", "ACCOUNTANT", "IT_ADMIN").

Blocks and polls until the invite is created by default (poll: false to instead get a Ramp.DeferredTaskRef back immediately).

deactivate(client, user_id)

@spec deactivate(Ramp.Client.t(), String.t()) :: :ok | {:error, Ramp.Error.t()}

Deactivates a user and cancels their associated cards.

get(client, user_id)

@spec get(Ramp.Client.t(), String.t()) ::
  {:ok, Ramp.Users.User.t()} | {:error, Ramp.Error.t()}

Fetches a single user by ID.

list(client, opts \\ [])

Returns a lazily auto-paginating Stream of Ramp.Users.Users.

list_page(client, opts \\ [])

@spec list_page(Ramp.Client.t(), [list_opt()]) ::
  {:ok, Ramp.Page.t(Ramp.Users.User.t())} | {:error, Ramp.Error.t()}

Fetches a single page of users. See Ramp.Page.

reactivate(client, user_id)

@spec reactivate(Ramp.Client.t(), String.t()) ::
  {:ok, Ramp.Users.User.t()} | {:error, Ramp.Error.t()}

Restores a previously deactivated user.

update(client, user_id, opts)

@spec update(Ramp.Client.t(), String.t(), [update_opt()]) ::
  {:ok, Ramp.Users.User.t()} | {:error, Ramp.Error.t()}

Updates a user's mutable fields.