Class: Nombaone::Resources::Prices

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

Overview

Prices — the amounts and cadences plans are sold at. Create and list them under a plan via nombaone.plans.prices; this namespace reads and deactivates them directly.

Prices are immutable once created — to change pricing, create a new price and deactivate the old one. Existing subscriptions keep the price they were sold at.

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

#deactivate(id, request_options: {}) ⇒ NombaObject

Deactivate a price so no new subscriptions can be created against it. Existing subscriptions are unaffected — prices are immutable history.

Parameters:

  • id (String)

    nbo…prc

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

Returns:

Raises:



48
49
50
# File 'lib/nombaone/resources/prices.rb', line 48

def deactivate(id, request_options: {})
  request(:post, "/prices/#{encode(id)}/deactivate", body: {}, options: request_options)
end

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

List prices across all plans, newest first.

Examples:

page = nombaone.prices.list(plan_ref: plan.id, active: true)

Parameters:

  • plan_ref (String) (defaults to: OMIT)

    filter to one plan's prices (nbo…pln). Note the wire filter name is planRef.

  • active (Boolean) (defaults to: OMIT)

    filter by the active flag.

  • 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:



35
36
37
38
39
# File 'lib/nombaone/resources/prices.rb', line 35

def list(plan_ref: OMIT, active: OMIT, limit: OMIT, cursor: OMIT, request_options: {})
  request_page("/prices",
               query: { plan_ref: plan_ref, active: active, limit: limit, cursor: cursor },
               options: request_options)
end

#retrieve(id, request_options: {}) ⇒ NombaObject

Retrieve a price by id.

Parameters:

  • id (String)

    nbo…prc

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

Returns:

Raises:



19
20
21
# File 'lib/nombaone/resources/prices.rb', line 19

def retrieve(id, request_options: {})
  request(:get, "/prices/#{encode(id)}", options: request_options)
end