Nombaone. Coupons
(Nomba One v0.1.0)
View Source
Coupons — discount rules you apply via Nombaone.Customers.apply_discount/4
or Nombaone.Subscriptions.apply_discount/4.
{:ok, coupon} =
Nombaone.Coupons.create(client, %{
code: "LAUNCH20",
percent_off: 20,
duration: "repeating",
duration_in_cycles: 3
})
Summary
Functions
Create a coupon. Set exactly one of :amount_off_in_kobo (integer kobo) or
:percent_off (1–100).
Raising variant of create/3.
List coupons, newest first. Optional: :limit, :cursor.
Raising variant of list/3.
Retrieve a coupon by id. Common errors: 404 COUPON_NOT_FOUND.
Raising variant of retrieve/3.
Update a coupon's :redeem_by, :max_redemptions, or :metadata.
Raising variant of update/4.
Functions
@spec create(Nombaone.Client.t(), map(), keyword()) :: {:ok, Nombaone.Coupon.t()} | {:error, Nombaone.Error.t()}
Create a coupon. Set exactly one of :amount_off_in_kobo (integer kobo) or
:percent_off (1–100).
Common errors: 422 COUPON_INVALID_DEFINITION.
@spec create!(Nombaone.Client.t(), map(), keyword()) :: Nombaone.Coupon.t()
Raising variant of create/3.
@spec list(Nombaone.Client.t(), map(), keyword()) :: {:ok, Nombaone.Page.t()} | {:error, Nombaone.Error.t()}
List coupons, newest first. Optional: :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.Coupon.t()} | {:error, Nombaone.Error.t()}
Retrieve a coupon by id. Common errors: 404 COUPON_NOT_FOUND.
@spec retrieve!(Nombaone.Client.t(), String.t(), keyword()) :: Nombaone.Coupon.t()
Raising variant of retrieve/3.
@spec update(Nombaone.Client.t(), String.t(), map(), keyword()) :: {:ok, Nombaone.Coupon.t()} | {:error, Nombaone.Error.t()}
Update a coupon's :redeem_by, :max_redemptions, or :metadata.
@spec update!(Nombaone.Client.t(), String.t(), map(), keyword()) :: Nombaone.Coupon.t()
Raising variant of update/4.