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

Inherits:
Object
  • Object
show all
Defined in:
lib/metronome_sdk/resources/v1/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:



131
132
133
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 131

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:



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 44

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:



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 21

def list(params = {})
  parsed, options = MetronomeSDK::V1::PlanListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "v1/plans",
    query: parsed,
    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:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/metronome_sdk/resources/v1/plans.rb', line 74

def list_charges(params)
  parsed, options = MetronomeSDK::V1::PlanListChargesParams.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/charges", plan_id],
    query: parsed,
    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:



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

def list_customers(params)
  parsed, options = MetronomeSDK::V1::PlanListCustomersParams.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/customers", plan_id],
    query: parsed,
    page: MetronomeSDK::Internal::CursorPage,
    model: MetronomeSDK::Models::V1::PlanListCustomersResponse,
    options: options
  )
end