Class: MethodRuby::Resources::Accounts::Subscriptions

Inherits:
Object
  • Object
show all
Defined in:
lib/method_ruby/resources/accounts/subscriptions.rb

Overview

Subscriptions for accounts

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Subscriptions

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

Parameters:



146
147
148
# File 'lib/method_ruby/resources/accounts/subscriptions.rb', line 146

def initialize(client:)
  @client = client
end

Instance Method Details

#create(account_id, enroll:, method_version:, idempotency_key: nil, request_options: {}) ⇒ MethodRuby::Models::Accounts::SubscriptionCreateResponse

Some parameter documentations has been truncated, see Models::Accounts::SubscriptionCreateParams for more details.

Creates a new subscription for the specified account.

Parameters:

  • account_id (String)

    Path param: Unique identifier for the account.

  • enroll (String)

    Body param: Subscription name to enroll.

  • method_version (Symbol, MethodRuby::Models::Accounts::SubscriptionCreateParams::MethodVersion)

    Header param: API version to use for this request. This spec targets ‘2025-12-01

  • idempotency_key (String)

    Header param: Idempotency key for safely retrying a write request. Reuse the sam

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

Returns:

See Also:



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/method_ruby/resources/accounts/subscriptions.rb', line 28

def create(, params)
  parsed, options = MethodRuby::Accounts::SubscriptionCreateParams.dump_request(params)
  header_params = {method_version: "method-version", idempotency_key: "idempotency-key"}
  @client.request(
    method: :post,
    path: ["accounts/%1$s/subscriptions", ],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: MethodRuby::Models::Accounts::SubscriptionCreateResponse,
    security: {secret_key: true},
    options: options
  )
end

#delete(sub_id, account_id:, method_version:, idempotency_key: nil, request_options: {}) ⇒ MethodRuby::Models::Accounts::SubscriptionDeleteResponse

Some parameter documentations has been truncated, see Models::Accounts::SubscriptionDeleteParams for more details.

Deletes an account subscription.

Parameters:

  • sub_id (String)

    Path param: Unique identifier for the account subscription.

  • account_id (String)

    Path param: Unique identifier for the account.

  • method_version (Symbol, MethodRuby::Models::Accounts::SubscriptionDeleteParams::MethodVersion)

    Header param: API version to use for this request. This spec targets ‘2025-12-01

  • idempotency_key (String)

    Header param: Idempotency key for safely retrying a write request. Reuse the sam

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

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/method_ruby/resources/accounts/subscriptions.rb', line 124

def delete(sub_id, params)
  parsed, options = MethodRuby::Accounts::SubscriptionDeleteParams.dump_request(params)
   =
    parsed.delete(:account_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["accounts/%1$s/subscriptions/%2$s", , sub_id],
    headers: parsed.transform_keys(
      method_version: "method-version",
      idempotency_key: "idempotency-key"
    ),
    model: MethodRuby::Models::Accounts::SubscriptionDeleteResponse,
    security: {secret_key: true},
    options: options
  )
end

#list(account_id, method_version:, request_options: {}) ⇒ MethodRuby::Models::Accounts::SubscriptionListResponse

Some parameter documentations has been truncated, see Models::Accounts::SubscriptionListParams for more details.

Returns a list of subscriptions for the specified account.

Parameters:

Returns:

See Also:



92
93
94
95
96
97
98
99
100
101
102
# File 'lib/method_ruby/resources/accounts/subscriptions.rb', line 92

def list(, params)
  parsed, options = MethodRuby::Accounts::SubscriptionListParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["accounts/%1$s/subscriptions", ],
    headers: parsed.transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::Accounts::SubscriptionListResponse,
    security: {secret_key: true},
    options: options
  )
end

#retrieve(sub_id, account_id:, method_version:, request_options: {}) ⇒ MethodRuby::Models::Accounts::SubscriptionRetrieveResponse

Some parameter documentations has been truncated, see Models::Accounts::SubscriptionRetrieveParams for more details.

Retrieves an account subscription by its unique identifier.

Parameters:

Returns:

See Also:



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/method_ruby/resources/accounts/subscriptions.rb', line 60

def retrieve(sub_id, params)
  parsed, options = MethodRuby::Accounts::SubscriptionRetrieveParams.dump_request(params)
   =
    parsed.delete(:account_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["accounts/%1$s/subscriptions/%2$s", , sub_id],
    headers: parsed.transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::Accounts::SubscriptionRetrieveResponse,
    security: {secret_key: true},
    options: options
  )
end