Class: MetronomeSDK::Resources::V1::Plans

Inherits:
Object
  • Object
show all
Defined in:
lib/metronome_sdk/resources/v1/plans.rb

Overview

[Plans](docs.metronome.com/pricing-and-packaging/create-plans/) determine the base pricing for a customer. Use these endpoints to add a plan to a customer, end a customer plan, retrieve plans, and retrieve plan details. Create plans in the [Metronome app](app.metronome.com/plans).

Instance Method Summary collapse

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.

Parameters:



138
139
140
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 138

def initialize(client:)
  @client = client
end

Instance Method Details

#get_details(plan_id:, request_options: {}) ⇒ MetronomeSDK::Models::V1::PlanGetDetailsResponse

Fetch high level details of a specific plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

Returns:

See Also:



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 49

def get_details(params)
  parsed, options = MetronomeSDK::V1::PlanGetDetailsParams.dump_request(params)
  plan_id =
    parsed.delete(:plan_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/planDetails/%1$s", plan_id],
    model: MetronomeSDK::Models::V1::PlanGetDetailsResponse,
    options: options
  )
end

#list(limit: nil, next_page: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::PlanListResponse>

List all available plans. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

  • limit (Integer)

    Max number of results that should be returned

  • next_page (String)

    Cursor that indicates where the next page of results should start.

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

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 25

def list(params = {})
  parsed, options = MetronomeSDK::V1::PlanListParams.dump_request(params)
  query = MetronomeSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/plans",
    query: query,
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::PlanListResponse,
    options: options
  )
end

#list_charges(plan_id:, limit: nil, next_page: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::PlanListChargesResponse>

Fetches a list of charges of a specific plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

  • plan_id (String)

    Path param

  • limit (Integer)

    Query param: Max number of results that should be returned

  • next_page (String)

    Query param: Cursor that indicates where the next page of results should start.

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

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 79

def list_charges(params)
  parsed, options = MetronomeSDK::V1::PlanListChargesParams.dump_request(params)
  query = MetronomeSDK::Internal::Util.encode_query_params(parsed)
  plan_id =
    parsed.delete(:plan_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/planDetails/%1$s/charges", plan_id],
    query: query,
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::PlanListChargesResponse,
    options: options
  )
end

#list_customers(plan_id:, limit: nil, next_page: nil, status: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::PlanListCustomersResponse>

Some parameter documentations has been truncated, see Models::V1::PlanListCustomersParams for more details.

Fetches a list of customers on a specific plan (by default, only currently active plans are included). This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

  • plan_id (String)

    Path param

  • limit (Integer)

    Query param: Max number of results that should be returned

  • next_page (String)

    Query param: Cursor that indicates where the next page of results should start.

  • status (Symbol, MetronomeSDK::Models::V1::PlanListCustomersParams::Status)

    Query param: Status of customers on a given plan. Defaults to ‘active`.

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

Returns:

See Also:



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 118

def list_customers(params)
  parsed, options = MetronomeSDK::V1::PlanListCustomersParams.dump_request(params)
  query = MetronomeSDK::Internal::Util.encode_query_params(parsed)
  plan_id =
    parsed.delete(:plan_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/planDetails/%1$s/customers", plan_id],
    query: query,
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::PlanListCustomersResponse,
    options: options
  )
end