Class: Orb::Resources::Plans::ExternalPlanID

Inherits:
Object
  • Object
show all
Defined in:
lib/orb/resources/plans/external_plan_id.rb,
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.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ ExternalPlanID

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 ExternalPlanID.

Parameters:



82
83
84
# File 'lib/orb/resources/plans/external_plan_id.rb', line 82

def initialize(client:)
  @client = client
end

Instance Method Details

#fetch(external_plan_id, request_options: {}) ⇒ Orb::Models::Plan

This endpoint is used to fetch plan details given an external_plan_id 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.

If multiple plans are found to contain the specified external_plan_id, the active plans will take priority over archived ones, and among those, the endpoint will return the most recently created plan.

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. "

Parameters:

Returns:

See Also:



70
71
72
73
74
75
76
77
# File 'lib/orb/resources/plans/external_plan_id.rb', line 70

def fetch(external_plan_id, params = {})
  @client.request(
    method: :get,
    path: ["plans/external_plan_id/%1$s", external_plan_id],
    model: Orb::Plan,
    options: params[:request_options]
  )
end

#update(other_external_plan_id, description: nil, external_plan_id: nil, metadata: nil, request_options: {}) ⇒ Orb::Models::Plan

Some parameter documentations has been truncated, see Models::Plans::ExternalPlanIDUpdateParams 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.

Parameters:

  • other_external_plan_id (String)
  • description (String, nil)

    An optional user-defined description of the plan.

  • external_plan_id (String, nil)

    An optional user-defined ID for this plan resource, used throughout the system a

  • metadata (Hash{Symbol=>String, nil}, nil)

    User-specified key/value pairs for the resource. Individual keys can be removed

  • request_options (Orb::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



34
35
36
37
38
39
40
41
42
43
# File 'lib/orb/resources/plans/external_plan_id.rb', line 34

def update(other_external_plan_id, params = {})
  parsed, options = Orb::Plans::ExternalPlanIDUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["plans/external_plan_id/%1$s", other_external_plan_id],
    body: parsed,
    model: Orb::Plan,
    options: options
  )
end