Class: Orb::Resources::Plans
- Inherits:
-
Object
- Object
- Orb::Resources::Plans
- Defined in:
- lib/orb/resources/plans.rb,
lib/orb/resources/plans/migrations.rb,
lib/orb/resources/plans/external_plan_id.rb,
sig/orb/resources/plans.rbs,
sig/orb/resources/plans/migrations.rbs,
sig/orb/resources/plans/external_plan_id.rbs
Overview
The Plan resource represents a plan that can be subscribed to by a customer. Plans define the billing behavior of the subscription. You can see more about how to configure prices in the Price resource.
Defined Under Namespace
Classes: ExternalPlanID, Migrations
Instance Attribute Summary collapse
-
#external_plan_id ⇒ Orb::Resources::Plans::ExternalPlanID
readonly
The Plan resource represents a plan that can be subscribed to by a customer.
-
#migrations ⇒ Orb::Resources::Plans::Migrations
readonly
The Plan resource represents a plan that can be subscribed to by a customer.
Instance Method Summary collapse
-
#create(currency:, name:, prices:, adjustments: nil, default_invoice_memo: nil, description: nil, external_plan_id: nil, metadata: nil, net_terms: nil, plan_phases: nil, status: nil, request_options: {}) ⇒ Orb::Models::Plan
Some parameter documentations has been truncated, see Models::PlanCreateParams for more details.
-
#fetch(plan_id, request_options: {}) ⇒ Orb::Models::Plan
This endpoint is used to fetch plan details given a plan identifier.
-
#initialize(client:) ⇒ Plans
constructor
private
A new instance of Plans.
-
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, limit: nil, status: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Plan>
Some parameter documentations has been truncated, see Models::PlanListParams for more details.
-
#update(plan_id, description: nil, external_plan_id: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::Plan
Some parameter documentations has been truncated, see Models::PlanUpdateParams for more details.
Constructor Details
#initialize(client:) ⇒ Plans
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Plans.
183 184 185 186 187 |
# File 'lib/orb/resources/plans.rb', line 183 def initialize(client:) @client = client @external_plan_id = Orb::Resources::Plans::ExternalPlanID.new(client: client) @migrations = Orb::Resources::Plans::Migrations.new(client: client) end |
Instance Attribute Details
#external_plan_id ⇒ Orb::Resources::Plans::ExternalPlanID (readonly)
The Plan resource represents a plan that can be subscribed to by a customer. Plans define the billing behavior of the subscription. You can see more about how to configure prices in the Price resource.
15 16 17 |
# File 'lib/orb/resources/plans.rb', line 15 def external_plan_id @external_plan_id end |
#migrations ⇒ Orb::Resources::Plans::Migrations (readonly)
The Plan resource represents a plan that can be subscribed to by a customer. Plans define the billing behavior of the subscription. You can see more about how to configure prices in the Price resource.
22 23 24 |
# File 'lib/orb/resources/plans.rb', line 22 def migrations @migrations end |
Instance Method Details
#create(currency:, name:, prices:, adjustments: nil, default_invoice_memo: nil, description: nil, external_plan_id: nil, metadata: nil, net_terms: nil, plan_phases: nil, status: nil, request_options: {}) ⇒ Orb::Models::Plan
Some parameter documentations has been truncated, see Models::PlanCreateParams for more details.
This endpoint allows creation of plans including their prices.
58 59 60 61 |
# File 'lib/orb/resources/plans.rb', line 58 def create(params) parsed, = Orb::PlanCreateParams.dump_request(params) @client.request(method: :post, path: "plans", body: parsed, model: Orb::Plan, options: ) end |
#fetch(plan_id, request_options: {}) ⇒ Orb::Models::Plan
This endpoint is used to fetch plan details given a plan identifier. It returns information about the prices included in the plan and their configuration, as well as the product that the plan is attached to.
Serialized prices
Orb supports a few different pricing models out of the box. Each of these models
is serialized differently in a given Price
object. The model_type field determines the key for the configuration object
that is present. A detailed explanation of price types can be found in the
Price schema.
Phases
Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized prices refer to all prices across all phases.
171 172 173 174 175 176 177 178 |
# File 'lib/orb/resources/plans.rb', line 171 def fetch(plan_id, params = {}) @client.request( method: :get, path: ["plans/%1$s", plan_id], model: Orb::Plan, options: params[:request_options] ) end |
#list(created_at_gt: nil, created_at_gte: nil, created_at_lt: nil, created_at_lte: nil, cursor: nil, limit: nil, status: nil, request_options: {}) ⇒ Orb::Internal::Page<Orb::Models::Plan>
Some parameter documentations has been truncated, see Models::PlanListParams for more details.
This endpoint returns a list of all plans for
an account in a list format. The list of plans is ordered starting from the most
recently created plan. The response also includes
pagination_metadata which lets the caller
retrieve the next page of results if they exist.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/orb/resources/plans.rb', line 127 def list(params = {}) parsed, = Orb::PlanListParams.dump_request(params) query = Orb::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "plans", query: query.transform_keys( created_at_gt: "created_at[gt]", created_at_gte: "created_at[gte]", created_at_lt: "created_at[lt]", created_at_lte: "created_at[lte]" ), page: Orb::Internal::Page, model: Orb::Plan, options: ) end |
#update(plan_id, description: nil, external_plan_id: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::Plan
Some parameter documentations has been truncated, see Models::PlanUpdateParams for more details.
This endpoint can be used to update the external_plan_id, description, and
metadata of an existing plan.
Other fields on a plan are currently immutable.
86 87 88 89 90 91 92 93 94 95 |
# File 'lib/orb/resources/plans.rb', line 86 def update(plan_id, params = {}) parsed, = Orb::PlanUpdateParams.dump_request(params) @client.request( method: :put, path: ["plans/%1$s", plan_id], body: parsed, model: Orb::Plan, options: ) end |