Class: Nombaone::Resources::PlanPrices

Inherits:
BaseResource show all
Defined in:
lib/nombaone/resources/plans.rb,
sig/nombaone/resources.rbs

Overview

Prices nested under a plan (create/list); reach nombaone.prices for reads and deactivation.

Instance Method Summary collapse

Methods inherited from BaseResource

#encode, #initialize, #request, #request_page

Constructor Details

This class inherits a constructor from Nombaone::Resources::BaseResource

Instance Method Details

#create(plan_id, unit_amount_in_kobo:, interval:, interval_count: OMIT, usage_type: OMIT, billing_scheme: OMIT, trial_period_days: OMIT, metadata: OMIT, request_options: {}) ⇒ NombaObject

Create a price under a plan. Prices are immutable once created.

Examples:

price = nombaone.plans.prices.create(plan.id, unit_amount_in_kobo: 250_000, interval: "month")

Parameters:

  • plan_id (String)

    nbo…pln

  • unit_amount_in_kobo (Integer)

    amount per unit per interval, integer kobo (₦1.00 = 100). 250_000 is ₦2,500 — not ₦250,000.

  • interval (String)

    "day" "week" "month" "year".

  • interval_count (Integer) (defaults to: OMIT)

    bill every N intervals (default 1).

  • usage_type (String) (defaults to: OMIT)

    "licensed" (default) or "metered".

  • billing_scheme (String) (defaults to: OMIT)

    "per_unit" (default) or "tiered".

  • trial_period_days (Integer) (defaults to: OMIT)

    free-trial days at subscribe time.

  • metadata (Hash) (defaults to: OMIT)
  • request_options (Hash) (defaults to: {})

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/nombaone/resources/plans.rb', line 24

def create(plan_id, unit_amount_in_kobo:, interval:, interval_count: OMIT, usage_type: OMIT,
           billing_scheme: OMIT, trial_period_days: OMIT, metadata: OMIT, request_options: {})
  request(:post, "/plans/#{encode(plan_id)}/prices",
          body: {
            unit_amount_in_kobo: unit_amount_in_kobo,
            interval: interval,
            interval_count: interval_count,
            usage_type: usage_type,
            billing_scheme: billing_scheme,
            trial_period_days: trial_period_days,
            metadata: ,
          },
          options: request_options)
end

#list(plan_id, limit: OMIT, cursor: OMIT, request_options: {}) ⇒ Page<NombaObject>

List a plan's prices, newest first.

Parameters:

  • plan_id (String)

    nbo…pln

  • limit (Integer) (defaults to: OMIT)

    page size, 1–100 (API default 20).

  • cursor (String) (defaults to: OMIT)

    opaque cursor from a previous page.

  • request_options (Hash) (defaults to: {})

Returns:



46
47
48
49
# File 'lib/nombaone/resources/plans.rb', line 46

def list(plan_id, limit: OMIT, cursor: OMIT, request_options: {})
  request_page("/plans/#{encode(plan_id)}/prices",
               query: { limit: limit, cursor: cursor }, options: request_options)
end