Nombaone. Plans
(Nomba One v0.1.0)
View Source
Plans — your catalog. Prices (amount + cadence) nest underneath a plan via
Nombaone.Plans.Prices.
Every function returns {:ok, result} or {:error, %Nombaone.Error{}} and
has a raising ! variant.
{:ok, plan} = Nombaone.Plans.create(client, %{name: "Pro"})
{:ok, price} =
Nombaone.Plans.Prices.create(client, plan.id, %{unit_amount_in_kobo: 250_000, interval: "month"})
Summary
Functions
Archive a plan — it stops being subscribable but its history stays.
Raising variant of archive/3.
Create a plan.
Raising variant of create/3.
List plans, newest first. Optional filters: :status (active or archived), :limit, :cursor.
Raising variant of list/3.
Retrieve a plan by id. Common errors: 404 PLAN_NOT_FOUND.
Raising variant of retrieve/3.
Update a plan's mutable fields (:name, :description, :metadata). Pass description: nil to clear it.
Raising variant of update/4.
Functions
@spec archive(Nombaone.Client.t(), String.t(), keyword()) :: {:ok, Nombaone.Plan.t()} | {:error, Nombaone.Error.t()}
Archive a plan — it stops being subscribable but its history stays.
Common errors: 409 PLAN_ALREADY_ARCHIVED, 409 PLAN_HAS_ACTIVE_SUBSCRIBERS
(migrate or cancel those subscriptions first).
@spec archive!(Nombaone.Client.t(), String.t(), keyword()) :: Nombaone.Plan.t()
Raising variant of archive/3.
@spec create(Nombaone.Client.t(), map(), keyword()) :: {:ok, Nombaone.Plan.t()} | {:error, Nombaone.Error.t()}
Create a plan.
Common errors: 409 PLAN_NAME_TAKEN.
Example
{:ok, plan} = Nombaone.Plans.create(client, %{name: "Pro", description: "Everything"})
@spec create!(Nombaone.Client.t(), map(), keyword()) :: Nombaone.Plan.t()
Raising variant of create/3.
@spec list(Nombaone.Client.t(), map(), keyword()) :: {:ok, Nombaone.Page.t()} | {:error, Nombaone.Error.t()}
List plans, newest first. Optional filters: :status (active or archived), :limit, :cursor.
@spec list!(Nombaone.Client.t(), map(), keyword()) :: Nombaone.Page.t()
Raising variant of list/3.
@spec retrieve(Nombaone.Client.t(), String.t(), keyword()) :: {:ok, Nombaone.Plan.t()} | {:error, Nombaone.Error.t()}
Retrieve a plan by id. Common errors: 404 PLAN_NOT_FOUND.
@spec retrieve!(Nombaone.Client.t(), String.t(), keyword()) :: Nombaone.Plan.t()
Raising variant of retrieve/3.
@spec update(Nombaone.Client.t(), String.t(), map(), keyword()) :: {:ok, Nombaone.Plan.t()} | {:error, Nombaone.Error.t()}
Update a plan's mutable fields (:name, :description, :metadata). Pass description: nil to clear it.
@spec update!(Nombaone.Client.t(), String.t(), map(), keyword()) :: Nombaone.Plan.t()
Raising variant of update/4.