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

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

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:



171
172
173
# File 'lib/metronome_sdk/resources/v1/customers/plans.rb', line 171

def initialize(client:)
  @client = client
end

Instance Method Details

#add(customer_id: , plan_id: , starting_on: , ending_before: nil, net_payment_terms_days: nil, overage_rate_adjustments: nil, price_adjustments: nil, trial_spec: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::Customers::PlanAddResponse

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

Associate an existing customer with a plan for a specified date range. See the [price adjustments documentation](plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details on the price adjustments. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/metronome_sdk/resources/v1/customers/plans.rb', line 71

def add(params)
  parsed, options = MetronomeSDK::V1::Customers::PlanAddParams.dump_request(params)
  customer_id =
    parsed.delete(:customer_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["v1/customers/%1$s/plans/add", customer_id],
    body: parsed,
    model: MetronomeSDK::Models::V1::Customers::PlanAddResponse,
    options: options
  )
end

#end_(customer_id: , customer_plan_id: , ending_before: nil, void_invoices: nil, void_stripe_invoices: nil, request_options: {}) ⇒ MetronomeSDK::Models::V1::Customers::PlanEndResponse

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

Change the end date of a customer’s plan. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

  • customer_id (String)

    Path param:

  • customer_plan_id (String)

    Path param: the ID of a customer-plan relationship

  • ending_before (Time)

    Body param: RFC 3339 timestamp for when the plan ends (exclusive) for this custo

  • void_invoices (Boolean)

    Body param: If true, plan end date can be before the last finalized invoice date

  • void_stripe_invoices (Boolean)

    Body param: Only applicable when void_invoices is set to true. If true, for ever

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

Returns:

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/metronome_sdk/resources/v1/customers/plans.rb', line 109

def end_(params)
  parsed, options = MetronomeSDK::V1::Customers::PlanEndParams.dump_request(params)
  customer_id =
    parsed.delete(:customer_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  customer_plan_id =
    parsed.delete(:customer_plan_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :post,
    path: ["v1/customers/%1$s/plans/%2$s/end", customer_id, customer_plan_id],
    body: parsed,
    model: MetronomeSDK::Models::V1::Customers::PlanEndResponse,
    options: options
  )
end

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

List the given customer’s plans in reverse-chronological order. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

  • customer_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:



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

def list(params)
  parsed, options = MetronomeSDK::V1::Customers::PlanListParams.dump_request(params)
  customer_id =
    parsed.delete(:customer_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/customers/%1$s/plans", customer_id],
    query: parsed,
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::Customers::PlanListResponse,
    options: options
  )
end

#list_price_adjustments(customer_id: , customer_plan_id: , limit: nil, next_page: nil, request_options: {}) ⇒ MetronomeSDK::Internal::CursorPage<MetronomeSDK::Models::V1::Customers::PlanListPriceAdjustmentsResponse>

Lists a customer plans adjustments. See the [price adjustments documentation](plans-docs.metronome.com/pricing/managing-plans/#price-adjustments) for details. This is a Plans (deprecated) endpoint. New clients should implement using Contracts.

Parameters:

  • customer_id (String)

    Path param:

  • customer_plan_id (String)

    Path param: the ID of a customer-plan relationship

  • 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:



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/metronome_sdk/resources/v1/customers/plans.rb', line 148

def list_price_adjustments(params)
  parsed, options = MetronomeSDK::V1::Customers::PlanListPriceAdjustmentsParams.dump_request(params)
  customer_id =
    parsed.delete(:customer_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  customer_plan_id =
    parsed.delete(:customer_plan_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["v1/customers/%1$s/plans/%2$s/priceAdjustments", customer_id, customer_plan_id],
    query: parsed,
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::Customers::PlanListPriceAdjustmentsResponse,
    options: options
  )
end