Class: Plaid::Transfer::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/plaid/transfer/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void

Parameters:



9
10
11
# File 'lib/plaid/transfer/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#authorization ⇒ Plaid::Authorization::Client

Returns:

  • (Plaid::Authorization::Client)


364
365
366
# File 'lib/plaid/transfer/client.rb', line 364

def authorization
  @authorization ||= Plaid::Transfer::Authorization::Client.new(client: @client)
end

#balance ⇒ Plaid::Balance::Client

Returns:

  • (Plaid::Balance::Client)


369
370
371
# File 'lib/plaid/transfer/client.rb', line 369

def balance
  @balance ||= Plaid::Transfer::Balance::Client.new(client: @client)
end

#cancel(request_options: {}, **params) ⇒ Plaid::Types::TransferCancelResponse

Use the /transfer/cancel endpoint to cancel a transfer. A transfer is eligible for cancellation if the cancellable property returned by /transfer/get is true.

Examples:

client.transfer.cancel(transfer_id: "transfer_id")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/plaid/transfer/client.rb', line 204

def cancel(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "transfer/cancel",
    body: Plaid::Transfer::Types::TransferCancelRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::TransferCancelResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#capabilities ⇒ Plaid::Capabilities::Client

Returns:

  • (Plaid::Capabilities::Client)


374
375
376
# File 'lib/plaid/transfer/client.rb', line 374

def capabilities
  @capabilities ||= Plaid::Transfer::Capabilities::Client.new(client: @client)
end

#configuration ⇒ Plaid::Configuration::Client

Returns:

  • (Plaid::Configuration::Client)


379
380
381
# File 'lib/plaid/transfer/client.rb', line 379

def configuration
  @configuration ||= Plaid::Transfer::Configuration::Client.new(client: @client)
end

#create(request_options: {}, **params) ⇒ Plaid::Types::TransferCreateResponse

Use the /transfer/create endpoint to initiate a new transfer. This endpoint is retryable and idempotent; if a transfer with the provided authorization_id has already been created, it will return the transfer details without creating a new transfer. A transfer may still be created if a 500 error is returned; to detect this scenario, use Transfer events.

Examples:

client.transfer.create(
  access_token: "access_token",
  account_id: "account_id",
  authorization_id: "authorization_id",
  description: "description"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/plaid/transfer/client.rb', line 86

def create(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "transfer/create",
    body: Plaid::Transfer::Types::TransferCreateRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::TransferCreateResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#diligence ⇒ Plaid::Diligence::Client

Returns:

  • (Plaid::Diligence::Client)


429
430
431
# File 'lib/plaid/transfer/client.rb', line 429

def diligence
  @diligence ||= Plaid::Transfer::Diligence::Client.new(client: @client)
end

#event ⇒ Plaid::Event::Client

Returns:

  • (Plaid::Event::Client)


399
400
401
# File 'lib/plaid/transfer/client.rb', line 399

def event
  @event ||= Plaid::Transfer::Event::Client.new(client: @client)
end

#get(request_options: {}, **params) ⇒ Plaid::Types::TransferGetResponse

The /transfer/get endpoint fetches information about the transfer corresponding to the given transfer_id or authorization_id. One of transfer_id or authorization_id must be populated but not both.

Examples:

client.transfer.get

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/plaid/transfer/client.rb', line 28

def get(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "transfer/get",
    body: Plaid::Transfer::Types::TransferGetRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::TransferGetResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#intent ⇒ Plaid::Intent::Client

Returns:

  • (Plaid::Intent::Client)


409
410
411
# File 'lib/plaid/transfer/client.rb', line 409

def intent
  @intent ||= Plaid::Transfer::Intent::Client.new(client: @client)
end

#ledger ⇒ Plaid::Ledger::Client

Returns:

  • (Plaid::Ledger::Client)


384
385
386
# File 'lib/plaid/transfer/client.rb', line 384

def ledger
  @ledger ||= Plaid::Transfer::Ledger::Client.new(client: @client)
end

#list(request_options: {}, **params) ⇒ Plaid::Internal::OffsetItemIterator

Use the /transfer/list endpoint to see a list of all your transfers and their statuses. Results are paginated; use the count and offset query parameters to retrieve the desired transfers.

Returns a Plaid::Internal::OffsetItemIterator that yields each Plaid::Types::Transfer in the transfers field of every page, requesting pages as they are needed. Call pages on it to get each page as a Plaid::Types::TransferListResponse, including its other fields.

No request is sent by this call. The first page is requested when you start iterating (or call load_first_page), so an API error is raised by the loop (or by load_first_page), not by this call.

Examples:

client.transfer.list

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/plaid/transfer/client.rb', line 144

def list(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  Plaid::Internal::OffsetItemIterator.new(
    initial_page: params[:offset],
    item_field: :transfers,
    has_next_field: nil,
    step: true
  ) do |next_page|
    params[:offset] = next_page
    request = Plaid::Internal::JSON::Request.new(
      base_url: request_options[:base_url],
      method: "POST",
      path: "transfer/list",
      body: Plaid::Transfer::Types::TransferListRequest.new(params).to_h,
      request_options: request_options
    )
    begin
      response = @client.send(request)
    rescue Net::HTTPRequestTimeout
      raise Plaid::Errors::TimeoutError
    end
    code = response.code.to_i
    if code.between?(200, 299)
      begin
        parsed_response = (response.body.to_s.empty? ? nil : Plaid::Types::TransferListResponse.load(response.body))
      rescue ::JSON::ParserError
        raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
      end
      [parsed_response, response]
    else
      error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
      error_types = {
        400 => Plaid::Types::PlaidError,
        401 => Plaid::Types::PlaidError,
        429 => Plaid::Types::PlaidError,
        500 => Plaid::Types::PlaidError,
        (400..499) => Plaid::Types::PlaidError,
        (500..599) => Plaid::Types::PlaidError
      }
      error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
      raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
    end
  end
end

#metrics ⇒ Plaid::Metrics::Client

Returns:

  • (Plaid::Metrics::Client)


394
395
396
# File 'lib/plaid/transfer/client.rb', line 394

def metrics
  @metrics ||= Plaid::Transfer::Metrics::Client.new(client: @client)
end

#migrate_account(request_options: {}, **params) ⇒ Plaid::Types::TransferMigrateAccountResponse

As an alternative to adding Items via Link, you can also use the /transfer/migrate_account endpoint to migrate previously-verified account and routing numbers to Plaid Items. This endpoint is also required when adding an Item for use with wire transfers; if you intend to create wire transfers on this account, you must provide wire_routing_number. Note that Items created in this way are not compatible with endpoints for other products, such as /accounts/balance/get, and can only be used with Transfer endpoints. If you require access to other endpoints, create the Item through Link instead. Access to /transfer/migrate_account is not enabled by default; to obtain access, contact your Plaid account manager or support.

Examples:

client.transfer.(
  account_number: "account_number",
  routing_number: "routing_number",
  account_type: "account_type"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/plaid/transfer/client.rb', line 264

def (request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "transfer/migrate_account",
    body: Plaid::Transfer::Types::TransferMigrateAccountRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::TransferMigrateAccountResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#originator ⇒ Plaid::Originator::Client

Returns:

  • (Plaid::Originator::Client)


389
390
391
# File 'lib/plaid/transfer/client.rb', line 389

def originator
  @originator ||= Plaid::Transfer::Originator::Client.new(client: @client)
end

#platform ⇒ Plaid::Platform::Client

Returns:

  • (Plaid::Platform::Client)


419
420
421
# File 'lib/plaid/transfer/client.rb', line 419

def platform
  @platform ||= Plaid::Transfer::Platform::Client.new(client: @client)
end

#questionnaire ⇒ Plaid::Questionnaire::Client

Returns:

  • (Plaid::Questionnaire::Client)


424
425
426
# File 'lib/plaid/transfer/client.rb', line 424

def questionnaire
  @questionnaire ||= Plaid::Transfer::Questionnaire::Client.new(client: @client)
end

#recover_return(request_options: {}, **params) ⇒ Plaid::Types::TransferReturnRecoverResponse

Use the /transfer/return/recover endpoint to notify Plaid that you have recovered some or all of the loss on a returned guaranteed transfer.

Recovery can be reported in full or in parts; the sum of recovered amounts across calls cannot exceed the guaranteed amount of the original transfer.

Examples:

client.transfer.recover_return(
  transfer_id: "transfer_id",
  amount: "amount",
  idempotency_key: "idempotency_key"
)

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/plaid/transfer/client.rb', line 322

def recover_return(request_options: {}, **params)
  params = Plaid::Internal::Types::Utils.normalize_keys(params)
  request = Plaid::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "transfer/return/recover",
    body: Plaid::Transfer::Types::TransferReturnRecoverRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Plaid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    begin
      (response.body.to_s.empty? ? nil : Plaid::Types::TransferReturnRecoverResponse.load(response.body))
    rescue ::JSON::ParserError
      raise Plaid::Errors::ResponseError.new(response.body, code: code, headers: response.to_hash)
    end
  else
    error_class = Plaid::Errors::ResponseError.subclass_for_code(code)
    error_types = {
      400 => Plaid::Types::PlaidError,
      401 => Plaid::Types::PlaidError,
      429 => Plaid::Types::PlaidError,
      500 => Plaid::Types::PlaidError,
      (400..499) => Plaid::Types::PlaidError,
      (500..599) => Plaid::Types::PlaidError
    }
    error_body = Plaid::Errors::ResponseError.load_error_body(code, response.body, error_types)
    raise error_class.new(response.body, code: code, body: error_body, headers: response.to_hash)
  end
end

#recurring ⇒ Plaid::Recurring::Client

Returns:

  • (Plaid::Recurring::Client)


359
360
361
# File 'lib/plaid/transfer/client.rb', line 359

def recurring
  @recurring ||= Plaid::Transfer::Recurring::Client.new(client: @client)
end

#refund ⇒ Plaid::Refund::Client

Returns:

  • (Plaid::Refund::Client)


434
435
436
# File 'lib/plaid/transfer/client.rb', line 434

def refund
  @refund ||= Plaid::Transfer::Refund::Client.new(client: @client)
end

#repayment ⇒ Plaid::Repayment::Client

Returns:

  • (Plaid::Repayment::Client)


414
415
416
# File 'lib/plaid/transfer/client.rb', line 414

def repayment
  @repayment ||= Plaid::Transfer::Repayment::Client.new(client: @client)
end

#sweep ⇒ Plaid::Sweep::Client

Returns:

  • (Plaid::Sweep::Client)


404
405
406
# File 'lib/plaid/transfer/client.rb', line 404

def sweep
  @sweep ||= Plaid::Transfer::Sweep::Client.new(client: @client)
end