Stripe.Billing.Alert (stripity_stripe v3.3.2)

View Source

A billing alert is a resource that notifies you when a certain usage threshold on a meter is crossed. For example, you might create a billing alert to notify you when a certain user made 100 API requests.

Summary

Types

t()

The billing.alert type.

The configuration of the usage threshold.

Functions

Reactivates this alert, allowing it to trigger again.

Archives this alert, removing it from the list view and APIs. This is non-reversible.

Creates a billing alert

Deactivates this alert, preventing it from triggering.

Lists billing active and inactive alerts

Retrieves a billing alert given an ID

Types

filters()

@type filters() :: %{optional(:customer) => binary(), optional(:type) => :customer}

t()

@type t() :: %Stripe.Billing.Alert{
  alert_type: binary(),
  id: binary(),
  livemode: boolean(),
  object: binary(),
  status: binary() | nil,
  title: binary(),
  usage_threshold: term() | nil
}

The billing.alert type.

  • alert_type Defines the type of the alert.
  • id Unique identifier for the object.
  • livemode Has the value true if the object exists in live mode or the value false if the object exists in test mode.
  • object String representing the object's type. Objects of the same type share the same value.
  • status Status of the alert. This can be active, inactive or archived.
  • title Title of the alert.
  • usage_threshold Encapsulates configuration of the alert to monitor usage on a specific Billing Meter.

usage_threshold()

@type usage_threshold() :: %{
  optional(:filters) => [filters()],
  optional(:gte) => integer(),
  optional(:meter) => binary(),
  optional(:recurrence) => :one_time
}

The configuration of the usage threshold.

Functions

activate(id, params \\ %{}, opts \\ [])

@spec activate(
  id :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Reactivates this alert, allowing it to trigger again.

Details

  • Method: post
  • Path: /v1/billing/alerts/{id}/activate

archive(id, params \\ %{}, opts \\ [])

@spec archive(
  id :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Archives this alert, removing it from the list view and APIs. This is non-reversible.

Details

  • Method: post
  • Path: /v1/billing/alerts/{id}/archive

create(params \\ %{}, opts \\ [])

@spec create(
  params :: %{
    optional(:alert_type) => :usage_threshold,
    optional(:expand) => [binary()],
    optional(:title) => binary(),
    optional(:usage_threshold) => usage_threshold()
  },
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Creates a billing alert

Details

  • Method: post
  • Path: /v1/billing/alerts

deactivate(id, params \\ %{}, opts \\ [])

@spec deactivate(
  id :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Deactivates this alert, preventing it from triggering.

Details

  • Method: post
  • Path: /v1/billing/alerts/{id}/deactivate

list(params \\ %{}, opts \\ [])

@spec list(
  params :: %{
    optional(:alert_type) => :usage_threshold,
    optional(:ending_before) => binary(),
    optional(:expand) => [binary()],
    optional(:limit) => integer(),
    optional(:meter) => binary(),
    optional(:starting_after) => binary()
  },
  opts :: Keyword.t()
) ::
  {:ok, Stripe.List.t(t())} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Lists billing active and inactive alerts

Details

  • Method: get
  • Path: /v1/billing/alerts

retrieve(id, params \\ %{}, opts \\ [])

@spec retrieve(
  id :: binary(),
  params :: %{optional(:expand) => [binary()]},
  opts :: Keyword.t()
) :: {:ok, t()} | {:error, Stripe.ApiErrors.t()} | {:error, term()}

Retrieves a billing alert given an ID

Details

  • Method: get
  • Path: /v1/billing/alerts/{id}