Class: Orb::Resources::Plans
- Inherits:
-
Object
- Object
- Orb::Resources::Plans
- Defined in:
- lib/orb/resources/plans.rb,
lib/orb/resources/plans/external_plan_id.rb
Defined Under Namespace
Classes: ExternalPlanID
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(currency: , name: , prices: , adjustments: nil, default_invoice_memo: 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](/core-concepts#plan-and-price) 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, 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.
163 164 165 166 |
# File 'lib/orb/resources/plans.rb', line 163 def initialize(client:) @client = client @external_plan_id = Orb::Resources::Plans::ExternalPlanID.new(client: client) end |
Instance Attribute Details
#external_plan_id ⇒ Orb::Resources::Plans::ExternalPlanID (readonly)
7 8 9 |
# File 'lib/orb/resources/plans.rb', line 7 def external_plan_id @external_plan_id end |
Instance Method Details
#create(currency: , name: , prices: , adjustments: nil, default_invoice_memo: 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.
41 42 43 44 |
# File 'lib/orb/resources/plans.rb', line 41 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](/core-concepts#plan-and-price) 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](/core-concepts#plan-and-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](/core-concepts#plan-and-price).
## Phases
Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized prices refer to all prices across all phases.
151 152 153 154 155 156 157 158 |
# File 'lib/orb/resources/plans.rb', line 151 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](/core-concepts#plan-and-price) 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`](/api-reference/pagination), which lets the caller retrieve the next page of results if they exist.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/orb/resources/plans.rb', line 108 def list(params = {}) parsed, = Orb::PlanListParams.dump_request(params) @client.request( method: :get, path: "plans", query: parsed.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, 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`, and `metadata` of an existing plan.
Other fields on a plan are currently immutable.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/orb/resources/plans.rb', line 67 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 |