AuroraMeter.Schema.Subscription (Aurora Meter v0.4.0)

View Source

A tenant's plan assignment. Created locally by AuroraMeter.subscribe/2 (free) or synced from the billing provider (Pro). One row per tenant.

status follows Stripe's vocabulary. Only entitled_statuses/0 grant the subscription's plan; any other status (canceled, unpaid, incomplete, ...) falls back to the configured default plan.

Summary

Functions

Builds a changeset for a subscription.

Whether a subscription currently grants its plan.

Statuses under which the subscription's plan is granted.

Types

t()

@type t() :: %AuroraMeter.Schema.Subscription{
  __meta__: term(),
  current_period_end: term(),
  current_period_start: term(),
  id: term(),
  inserted_at: term(),
  plan_id: term(),
  provider: term(),
  provider_customer_id: term(),
  provider_subscription_id: term(),
  status: term(),
  tenant_key: term(),
  updated_at: term()
}

Functions

changeset(subscription, attrs)

@spec changeset(t(), map()) :: Ecto.Changeset.t()

Builds a changeset for a subscription.

entitled?(subscription)

@spec entitled?(t()) :: boolean()

Whether a subscription currently grants its plan.

Examples

iex> AuroraMeter.Schema.Subscription.entitled?(%AuroraMeter.Schema.Subscription{status: "canceled"})
false

entitled_statuses()

@spec entitled_statuses() :: [String.t()]

Statuses under which the subscription's plan is granted.

Examples

iex> "active" in AuroraMeter.Schema.Subscription.entitled_statuses()
true