Ramp.Limits (ramp v1.0.0)

Copy Markdown View Source

The Limits resource (spend controls): creating, listing, updating, and terminating spend limits.

Summary

Functions

Creates a new spend limit for user_id. Blocks and polls until creation completes by default (poll: false for a Ramp.DeferredTaskRef).

Fetches a single limit by ID.

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

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

Permanently terminates a limit. This action is irreversible. Blocks and polls until termination completes by default (poll: false for a Ramp.DeferredTaskRef).

Updates a limit's display name, balance, and/or restrictions.

Types

create_opt()

@type create_opt() ::
  {:balance, Ramp.Money.t()}
  | {:restrictions, Ramp.Limits.Restrictions.t()}
  | {:spend_program_id, String.t()}
  | {:idempotency_key, String.t()}
  | {:poll, boolean()}
  | {:poll_timeout_ms, pos_integer()}

list_opt()

@type list_opt() ::
  {:start, String.t()}
  | {:page_size, pos_integer()}
  | {:user_id, String.t()}
  | {:status, String.t()}
  | {:entity_id, String.t()}

update_opt()

@type update_opt() ::
  {:display_name, String.t()}
  | {:balance, Ramp.Money.t()}
  | {:restrictions, Ramp.Limits.Restrictions.t()}

Functions

create(client, user_id, display_name, opts \\ [])

@spec create(Ramp.Client.t(), String.t(), String.t(), [create_opt()]) ::
  {:ok, Ramp.Limits.Limit.t()}
  | {:ok, Ramp.DeferredTaskRef.t()}
  | {:error, Ramp.Error.t()}

Creates a new spend limit for user_id. Blocks and polls until creation completes by default (poll: false for a Ramp.DeferredTaskRef).

Example

Ramp.Limits.create(client, "usr_123", "Q3 Travel Budget",
  balance: %Ramp.Money{amount: 500_000, currency_code: "USD"},
  restrictions: %Ramp.Limits.Restrictions{categories: ["AIRLINES"]}
)

get(client, limit_id)

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

Fetches a single limit by ID.

list(client, opts \\ [])

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

list_page(client, opts \\ [])

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

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

terminate(client, limit_id, opts \\ [])

@spec terminate(Ramp.Client.t(), String.t(),
  poll: boolean(),
  poll_timeout_ms: pos_integer()
) ::
  :ok | {:ok, Ramp.DeferredTaskRef.t()} | {:error, Ramp.Error.t()}

Permanently terminates a limit. This action is irreversible. Blocks and polls until termination completes by default (poll: false for a Ramp.DeferredTaskRef).

update(client, limit_id, opts)

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

Updates a limit's display name, balance, and/or restrictions.