Class: Nombaone::Resources::Plans
- Inherits:
-
BaseResource
- Object
- BaseResource
- Nombaone::Resources::Plans
- Defined in:
- lib/nombaone/resources/plans.rb,
sig/nombaone/resources.rbs
Overview
Plans — your catalog. A plan holds the name and description; its prices
(amount + cadence) live underneath it (nombaone.plans.prices).
Instance Method Summary collapse
-
#archive(id, request_options: {}) ⇒ NombaObject
Archive a plan — it stops being subscribable but its history stays.
-
#create(name:, description: OMIT, metadata: OMIT, request_options: {}) ⇒ NombaObject
Create a plan.
-
#list(status: OMIT, limit: OMIT, cursor: OMIT, request_options: {}) ⇒ Page<NombaObject>
List plans, newest first.
-
#prices ⇒ PlanPrices
Prices nested under a plan.
-
#retrieve(id, request_options: {}) ⇒ NombaObject
Retrieve a plan by id.
-
#update(id, name: OMIT, description: OMIT, metadata: OMIT, request_options: {}) ⇒ NombaObject
Update a plan's mutable fields.
Methods inherited from BaseResource
#encode, #initialize, #request, #request_page
Constructor Details
This class inherits a constructor from Nombaone::Resources::BaseResource
Instance Method Details
#archive(id, request_options: {}) ⇒ NombaObject
Archive a plan — it stops being subscribable but its history stays.
124 125 126 |
# File 'lib/nombaone/resources/plans.rb', line 124 def archive(id, request_options: {}) request(:post, "/plans/#{encode(id)}/archive", body: {}, options: ) end |
#create(name:, description: OMIT, metadata: OMIT, request_options: {}) ⇒ NombaObject
Create a plan.
73 74 75 76 77 |
# File 'lib/nombaone/resources/plans.rb', line 73 def create(name:, description: OMIT, metadata: OMIT, request_options: {}) request(:post, "/plans", body: { name: name, description: description, metadata: }, options: ) end |
#list(status: OMIT, limit: OMIT, cursor: OMIT, request_options: {}) ⇒ Page<NombaObject>
List plans, newest first.
110 111 112 113 114 |
# File 'lib/nombaone/resources/plans.rb', line 110 def list(status: OMIT, limit: OMIT, cursor: OMIT, request_options: {}) request_page("/plans", query: { status: status, limit: limit, cursor: cursor }, options: ) end |
#prices ⇒ PlanPrices
Prices nested under a plan.
61 62 63 |
# File 'lib/nombaone/resources/plans.rb', line 61 def prices @prices ||= PlanPrices.new(@client) end |
#retrieve(id, request_options: {}) ⇒ NombaObject
Retrieve a plan by id.
85 86 87 |
# File 'lib/nombaone/resources/plans.rb', line 85 def retrieve(id, request_options: {}) request(:get, "/plans/#{encode(id)}", options: ) end |
#update(id, name: OMIT, description: OMIT, metadata: OMIT, request_options: {}) ⇒ NombaObject
Update a plan's mutable fields. At least one field is required.
97 98 99 100 101 |
# File 'lib/nombaone/resources/plans.rb', line 97 def update(id, name: OMIT, description: OMIT, metadata: OMIT, request_options: {}) request(:patch, "/plans/#{encode(id)}", body: { name: name, description: description, metadata: }, options: ) end |