Class: MethodRuby::Resources::Accounts::PaymentInstruments

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

Overview

Payment instruments for accounts

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ PaymentInstruments

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

Parameters:



157
158
159
# File 'lib/method_ruby/resources/accounts/payment_instruments.rb', line 157

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

Creates a new payment instrument for the specified account.

Parameters:

Returns:

See Also:



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

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

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

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

Closes an account payment instrument. This endpoint is only available starting with API version ‘2025-12-01`.

Parameters:

  • pmt_ins_id (String)

    Path param: Unique identifier for the account payment instrument.

  • account_id (String)

    Path param: Unique identifier for the account.

  • method_version (Symbol, MethodRuby::Models::Accounts::PaymentInstrumentDeleteParams::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:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/method_ruby/resources/accounts/payment_instruments.rb', line 135

def delete(pmt_ins_id, params)
  parsed, options = MethodRuby::Accounts::PaymentInstrumentDeleteParams.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/payment_instruments/%2$s", , pmt_ins_id],
    headers: parsed.transform_keys(
      method_version: "method-version",
      idempotency_key: "idempotency-key"
    ),
    model: MethodRuby::Models::Accounts::PaymentInstrumentDeleteResponse,
    security: {secret_key: true},
    options: options
  )
end

#list(account_id, method_version:, page: nil, page_cursor: nil, page_limit: nil, request_options: {}) ⇒ MethodRuby::Models::Accounts::PaymentInstrumentListResponse

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

Returns a list of payment instruments for the specified account.

Parameters:

  • account_id (String)

    Path param: Unique identifier for the account.

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

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

  • page (Integer)

    Query param: Page number for pagination (1-indexed).

  • page_cursor (String)

    Query param: Cursor for cursor-based pagination. Use the value from ‘Pagination-

  • page_limit (Integer)

    Query param: Number of items per page.

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

Returns:

See Also:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/method_ruby/resources/accounts/payment_instruments.rb', line 99

def list(, params)
  query_params = [:page, :page_cursor, :page_limit]
  parsed, options = MethodRuby::Accounts::PaymentInstrumentListParams.dump_request(params)
  query = MethodRuby::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["accounts/%1$s/payment_instruments", ],
    query: query,
    headers: parsed.except(*query_params).transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::Accounts::PaymentInstrumentListResponse,
    security: {secret_key: true},
    options: options
  )
end

#retrieve(pmt_ins_id, account_id:, method_version:, request_options: {}) ⇒ MethodRuby::Models::Accounts::PaymentInstrumentRetrieveResponse

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

Retrieves an account payment instrument by its unique identifier.

Parameters:

Returns:

See Also:



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

def retrieve(pmt_ins_id, params)
  parsed, options = MethodRuby::Accounts::PaymentInstrumentRetrieveParams.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/payment_instruments/%2$s", , pmt_ins_id],
    headers: parsed.transform_keys(method_version: "method-version"),
    model: MethodRuby::Models::Accounts::PaymentInstrumentRetrieveResponse,
    security: {secret_key: true},
    options: options
  )
end