didit-sdk 2.29.0 → 2.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,6 +81,788 @@ module Didit
81
81
  request_options: request_options
82
82
  )
83
83
  end
84
+
85
+ # Cancel a bank link
86
+ #
87
+ # Cancels a link that is not completed yet; its url and token stop working. Cancelling a link that is already
88
+ # cancelled, expired, failed or completed answers `200` and returns it unchanged, so it is safe to repeat. A
89
+ # completed link keeps its connection.
90
+ #
91
+ # +POST /v3/bank/links/{id}/cancel/+
92
+ #
93
+ # @param id [String] The link id.
94
+ # @param idempotency_key [String] sent as the Idempotency-Key header
95
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
96
+ # @return [Didit::Types::BankLink]
97
+ def cancel_link(id, idempotency_key: OMIT, request_options: nil)
98
+ @client.request(
99
+ :post,
100
+ "/v3/bank/links/{id}/cancel/",
101
+ path_params: { "id" => id },
102
+ headers: { "Idempotency-Key" => idempotency_key },
103
+ response: Types::BankLink,
104
+ request_options: request_options
105
+ )
106
+ end
107
+
108
+ # Create a bank link
109
+ #
110
+ # Creates a Bank Link: one run of the flow in which a person connects a bank, or renews a connection. Send the
111
+ # person to `url`. The `client_token` is for Didit's embedded Bank Link, which is not released yet: open the
112
+ # `url` today. A completed link yields a connection.
113
+ #
114
+ # The smallest request is `{}` plus what you want. Defaults: `mode` connect, `access` one_time, `data` accounts
115
+ # only, `history_days` 90, `ownership.compare` none, `segment` any, `duplicates` reuse,
116
+ # `allow_one_time_fallback` false, and for ongoing access a consent as long as the bank allows.
117
+ #
118
+ # The response carries the quote: the price is pinned to the link and charged as quoted. The API key never
119
+ # reaches a browser or an app: only the `url` does.
120
+ #
121
+ # Confirm the outcome yourself with `get_link` or the `bank.link.completed` webhook; never trust a link id sent
122
+ # by the browser. History: send `history_from` or `history_days`, not both. Where the bank allows, ongoing
123
+ # access keeps working until the consent ends; the real date is on each connection.
124
+ #
125
+ # Needs an API key with the Bank data permission (`bank-data`): write for this operation, which changes
126
+ # something. A key with full access does not include it: grant it explicitly when you create the key, or the
127
+ # call answers `403 bank_data_access_denied`.
128
+ #
129
+ # +POST /v3/bank/links/+
130
+ #
131
+ # @param mode [String] `connect` (default) creates a new connection. `renew` needs `connection_id` and reuses
132
+ # that connection's settings.
133
+ # @param connection_id [String] The connection to renew. Only with `mode: renew`.
134
+ # @param access [String] `one_time` (default) reads the data once. `ongoing` keeps access open until the consent
135
+ # ends or someone stops it. With `institution_id` set, a bank that cannot keep access open answers `400
136
+ # ongoing_access_not_available` before any screen. Without it, the bank picker lists only banks that can.
137
+ # @param country [String] Optional. Without it the person picks among the countries your application enabled. It
138
+ # has to be a country Bank Link serves; any other, `ZZZ` included, answers `400 invalid_request` with `field:
139
+ # country`. An empty request body stays valid.
140
+ # @param institution_id [String] Optional bank to preselect, from `list_institutions`. Skips the picker.
141
+ # @param segment [String] Filters the picker and tells the bank which login to open where the bank separates
142
+ # them. Default `any`.
143
+ # @param data [Array<String>] What to read. `accounts` is always included: name, type, currency, identifiers and
144
+ # the holder name where the bank shares it. Default `["accounts"]`.
145
+ # @param history_days [Integer] Days of transaction history to request, 1 to 365, default 90. The bank may
146
+ # deliver less: each account reports what it delivered in `history_coverage`. Cannot be sent with
147
+ # `history_from`.
148
+ # @param history_from [Date, String] Start date of the history to request, instead of `history_days`. Cannot be
149
+ # sent with `history_days`: both together answer `400 history_window_ambiguous`. A date older than 365 days, or
150
+ # in the future, answers `400 window_not_available`.
151
+ # @param extended_history [String] `allow_extra_auth` lets a bank that asks for one more confirmation release
152
+ # older history.
153
+ # @param consent_days [Integer] Ongoing only. How many days to ask the bank to keep access open, 1 or more.
154
+ # Default: the longest the bank allows. The connection reports the date the bank actually granted in
155
+ # `consent.expires_at`. With `access: one_time` it answers `400 invalid_request` with `field: consent_days`.
156
+ # @param ownership [Hash] Optional comparison of the account holder with a person or a company.
157
+ # @param end_user [Hash] The person or company that connects the account.
158
+ # @param redirect_url [String] Where the browser goes at the end, with `link_id`, `status` and a signed `state`
159
+ # (for display only: the webhook and `get_link` are authoritative). In a sandbox application a plain `http`
160
+ # address of `localhost`, `127.0.0.1` or `[::1]` (any port and path, no credentials, no fragment) needs no
161
+ # registration. Any other address answers `400 redirect_url_not_registered`: registering other addresses is n...
162
+ # @param allowed_origins [Array<String>] Accepted and not used today: reserved for Didit's embedded Bank Link,
163
+ # which is not released yet. HTTPS origins, up to 50.
164
+ # @param language [String] Optional language code such as `es` or `pt-BR`. Otherwise the browser language.
165
+ # @param vendor_data [String] Your own reference, returned on the link and the connection.
166
+ # @param expires_in [Integer] Lifetime of the link in seconds, 300 to 86400. Default 3600.
167
+ # @param duplicates [String] `reuse` (default) completes a link that resolves to accounts you already share as a
168
+ # renewal of that connection. `allow` creates an independent second connection.
169
+ # @param allow_one_time_fallback [Boolean] With `ongoing`, lets the person continue with a one-time read at a
170
+ # bank that cannot keep access open, after confirming the reduced access on its own screen. The quote shows what
171
+ # that costs. Only with `access: ongoing`: with one-time access it answers `400 invalid_request` with `field:
172
+ # allow_one_time_fallback`.
173
+ # @param accept_reduced_grant [Boolean] When the bank or the person grants less than you asked for, complete the
174
+ # link and charge only the granted scopes. Otherwise the link ends `failed` with `reduced_grant` and nothing is
175
+ # charged.
176
+ # @param sandbox [Hash] Sandbox applications only: picks the Didit Test Bank customer. Ignored in a live
177
+ # application.
178
+ # @param idempotency_key [String] sent as the Idempotency-Key header
179
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
180
+ # @return [Didit::Types::BankLink]
181
+ def create_link(
182
+ mode: OMIT,
183
+ connection_id: OMIT,
184
+ access: OMIT,
185
+ country: OMIT,
186
+ institution_id: OMIT,
187
+ segment: OMIT,
188
+ data: OMIT,
189
+ history_days: OMIT,
190
+ history_from: OMIT,
191
+ extended_history: OMIT,
192
+ consent_days: OMIT,
193
+ ownership: OMIT,
194
+ end_user: OMIT,
195
+ redirect_url: OMIT,
196
+ allowed_origins: OMIT,
197
+ language: OMIT,
198
+ vendor_data: OMIT,
199
+ expires_in: OMIT,
200
+ duplicates: OMIT,
201
+ allow_one_time_fallback: OMIT,
202
+ accept_reduced_grant: OMIT,
203
+ sandbox: OMIT,
204
+ idempotency_key: OMIT,
205
+ request_options: nil
206
+ )
207
+ @client.request(
208
+ :post,
209
+ "/v3/bank/links/",
210
+ body: {
211
+ "mode" => mode,
212
+ "connection_id" => connection_id,
213
+ "access" => access,
214
+ "country" => country,
215
+ "institution_id" => institution_id,
216
+ "segment" => segment,
217
+ "data" => data,
218
+ "history_days" => history_days,
219
+ "history_from" => history_from,
220
+ "extended_history" => extended_history,
221
+ "consent_days" => consent_days,
222
+ "ownership" => ownership,
223
+ "end_user" => end_user,
224
+ "redirect_url" => redirect_url,
225
+ "allowed_origins" => allowed_origins,
226
+ "language" => language,
227
+ "vendor_data" => vendor_data,
228
+ "expires_in" => expires_in,
229
+ "duplicates" => duplicates,
230
+ "allow_one_time_fallback" => allow_one_time_fallback,
231
+ "accept_reduced_grant" => accept_reduced_grant,
232
+ "sandbox" => sandbox
233
+ },
234
+ headers: { "Idempotency-Key" => idempotency_key },
235
+ response: Types::BankLink,
236
+ request_options: request_options
237
+ )
238
+ end
239
+
240
+ # Delete a bank connection
241
+ #
242
+ # Deletes the connection's bank data and stops access at the bank. Deletion is immediate and irreversible: when
243
+ # the call returns, the connection's accounts, balances, transactions, sync history, consent records and
244
+ # ownership results are deleted, and its data operations (refresh, sync runs, accounts, balances, transactions
245
+ # and the change feed) answer `409 connection_not_active`.
246
+ #
247
+ # A deleted connection reads as a minimal record: its id, `status: deleted`, the reason, its dates and its
248
+ # `erasure` record (`requested_at`, `erased_at` and `status`, the confirmation of the deletion: `pending` while
249
+ # it is being confirmed, including the end of access at the bank, `erased` once confirmed, `failed` if the
250
+ # confirmation has not arrived yet and is repeated automatically, with nothing needed from you). It holds no
251
+ # accounts, balances, transactions, consent or sync data. `bank.connection.deleted` confirms the deletion.
252
+ #
253
+ # Not affected: your other connections, the charges already made (they are not refunded), and any data you
254
+ # already downloaded, which is your own copy. Repeating the call is safe. To stop access without deleting, use
255
+ # `revoke_connection`.
256
+ #
257
+ # Needs an API key with the Bank data permission (`bank-data`): write for this operation, which changes
258
+ # something. A key with full access does not include it: grant it explicitly when you create the key, or the
259
+ # call answers `403 bank_data_access_denied`.
260
+ #
261
+ # +DELETE /v3/bank/connections/{id}/+
262
+ #
263
+ # @param id [String] The connection id.
264
+ # @param idempotency_key [String] sent as the Idempotency-Key header
265
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
266
+ # @return [Didit::Types::BankConnectionDeletion]
267
+ def delete_connection(id, idempotency_key: OMIT, request_options: nil)
268
+ @client.request(
269
+ :delete,
270
+ "/v3/bank/connections/{id}/",
271
+ path_params: { "id" => id },
272
+ headers: { "Idempotency-Key" => idempotency_key },
273
+ response: Types::BankConnectionDeletion,
274
+ request_options: request_options
275
+ )
276
+ end
277
+
278
+ # Get an account
279
+ #
280
+ # Returns one account with full identifiers, holders, sync state and `history_coverage`, which says what the
281
+ # bank delivered of the history you asked for. `sync.last_synced_at` is when the data was fetched from the bank,
282
+ # not when you read it.
283
+ #
284
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
285
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
286
+ # bank_data_access_denied`. A sandbox application reads its Test Bank data with the key alone. A request without
287
+ # an API key (client credentials) is refused on raw data with the same `403`.
288
+ #
289
+ # +GET /v3/bank/accounts/{account_id}/+
290
+ #
291
+ # @param account_id [String] The account id.
292
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
293
+ # @return [Didit::Types::BankAccount]
294
+ def get_account(account_id, request_options: nil)
295
+ @client.request(
296
+ :get,
297
+ "/v3/bank/accounts/{account_id}/",
298
+ path_params: { "account_id" => account_id },
299
+ response: Types::BankAccount,
300
+ request_options: request_options
301
+ )
302
+ end
303
+
304
+ # Get account balances
305
+ #
306
+ # Returns the typed balances of an account with their reference dates. Balances are replaced at each sync.
307
+ #
308
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
309
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
310
+ # bank_data_access_denied`. A sandbox application reads its Test Bank data with the key alone. A request without
311
+ # an API key (client credentials) is refused on raw data with the same `403`.
312
+ #
313
+ # +GET /v3/bank/accounts/{account_id}/balances/+
314
+ #
315
+ # @param account_id [String] The account id.
316
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
317
+ # @return [Didit::Types::BankBalances]
318
+ def get_balances(account_id, request_options: nil)
319
+ @client.request(
320
+ :get,
321
+ "/v3/bank/accounts/{account_id}/balances/",
322
+ path_params: { "account_id" => account_id },
323
+ response: Types::BankBalances,
324
+ request_options: request_options
325
+ )
326
+ end
327
+
328
+ # Get a bank connection
329
+ #
330
+ # Returns the connection with its consent, sync state and a summary of each account. Read the data itself with
331
+ # the accounts, balances and transactions operations. A connection that was deleted reads as a minimal record:
332
+ # its id, `status: deleted`, the reason, its dates and its `erasure` status, and no accounts, balances,
333
+ # transactions, consent or sync data.
334
+ #
335
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
336
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
337
+ # bank_data_access_denied`.
338
+ #
339
+ # +GET /v3/bank/connections/{id}/+
340
+ #
341
+ # @param id [String] The connection id.
342
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
343
+ # @return [Didit::Types::BankConnection]
344
+ def get_connection(id, request_options: nil)
345
+ @client.request(
346
+ :get,
347
+ "/v3/bank/connections/{id}/",
348
+ path_params: { "id" => id },
349
+ response: Types::BankConnection,
350
+ request_options: request_options
351
+ )
352
+ end
353
+
354
+ # Get bank data coverage
355
+ #
356
+ # Returns one entry per country: whether bank sign-in and the account check are available, and whether ongoing
357
+ # access is available, with how many banks offer it, the longest consent and deepest history any of them allows,
358
+ # and whether business accounts are supported. Ongoing access is counted only where a bank is switched on for
359
+ # it. Use it to decide which countries to offer; use `list_institutions` for a single bank.
360
+ #
361
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
362
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
363
+ # bank_data_access_denied`.
364
+ #
365
+ # +GET /v3/bank/coverage/+
366
+ #
367
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
368
+ # @return [Didit::Types::BankCoverage]
369
+ def get_coverage(request_options: nil)
370
+ @client.request(
371
+ :get,
372
+ "/v3/bank/coverage/",
373
+ response: Types::BankCoverage,
374
+ request_options: request_options
375
+ )
376
+ end
377
+
378
+ # Get an institution
379
+ #
380
+ # Returns one bank with its capabilities. The id is Didit's slug, as listed by `list_institutions`.
381
+ #
382
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
383
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
384
+ # bank_data_access_denied`.
385
+ #
386
+ # +GET /v3/bank/institutions/{id}/+
387
+ #
388
+ # @param id [String] The institution id, for example `es-banco-norte`.
389
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
390
+ # @return [Didit::Types::BankInstitution]
391
+ def get_institution(id, request_options: nil)
392
+ @client.request(
393
+ :get,
394
+ "/v3/bank/institutions/{id}/",
395
+ path_params: { "id" => id },
396
+ response: Types::BankInstitution,
397
+ request_options: request_options
398
+ )
399
+ end
400
+
401
+ # Get a bank link
402
+ #
403
+ # Returns the status of a link and, once it is `completed`, its `connection_id` and `check_id`. This is the
404
+ # authoritative answer: call it from your server after the browser reports success, or on the
405
+ # `bank.link.completed` webhook.
406
+ #
407
+ # A link that fails is not an HTTP error: it reads `200` with `status: failed` and an `error` object, for
408
+ # example `duplicate_conflict` with `conflicts_with`. `url` and `client_token` are returned only when the link
409
+ # is created.
410
+ #
411
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
412
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
413
+ # bank_data_access_denied`.
414
+ #
415
+ # +GET /v3/bank/links/{id}/+
416
+ #
417
+ # @param id [String] The link id.
418
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
419
+ # @return [Didit::Types::BankLink]
420
+ def get_link(id, request_options: nil)
421
+ @client.request(
422
+ :get,
423
+ "/v3/bank/links/{id}/",
424
+ path_params: { "id" => id },
425
+ response: Types::BankLink,
426
+ request_options: request_options
427
+ )
428
+ end
429
+
430
+ # Get a sync run
431
+ #
432
+ # Returns one sync run with its results per account and resource.
433
+ #
434
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
435
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
436
+ # bank_data_access_denied`.
437
+ #
438
+ # +GET /v3/bank/connections/{id}/sync-runs/{sync_id}/+
439
+ #
440
+ # @param id [String] The connection id.
441
+ # @param sync_id [String] The sync run id.
442
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
443
+ # @return [Didit::Types::BankSyncRun]
444
+ def get_sync_run(id, sync_id, request_options: nil)
445
+ @client.request(
446
+ :get,
447
+ "/v3/bank/connections/{id}/sync-runs/{sync_id}/",
448
+ path_params: { "id" => id, "sync_id" => sync_id },
449
+ response: Types::BankSyncRun,
450
+ request_options: request_options
451
+ )
452
+ end
453
+
454
+ # List accounts of a connection
455
+ #
456
+ # Lists every account of the connection, oldest first, with full identifiers and holders. A read never bills.
457
+ #
458
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
459
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
460
+ # bank_data_access_denied`. A sandbox application reads its Test Bank data with the key alone. A request without
461
+ # an API key (client credentials) is refused on raw data with the same `403`.
462
+ #
463
+ # +GET /v3/bank/connections/{id}/accounts/+
464
+ #
465
+ # @param id [String] The connection id.
466
+ # @param limit [Integer] Page size, 1 to 500. Default 100.
467
+ # @param cursor [String] Opaque cursor from the previous page's `next_cursor`.
468
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
469
+ # @return [Didit::Types::BankAccountList]
470
+ def list_accounts(id, limit: OMIT, cursor: OMIT, request_options: nil)
471
+ @client.request(
472
+ :get,
473
+ "/v3/bank/connections/{id}/accounts/",
474
+ path_params: { "id" => id },
475
+ query: {
476
+ "limit" => limit,
477
+ "cursor" => cursor
478
+ },
479
+ response: Types::BankAccountList,
480
+ request_options: request_options
481
+ )
482
+ end
483
+
484
+ # List bank connections
485
+ #
486
+ # Lists the connections of your application, newest first, with cursor pagination. All filters apply inside your
487
+ # application and environment.
488
+ #
489
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
490
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
491
+ # bank_data_access_denied`.
492
+ #
493
+ # In this list `sync.budgets` shows only the budgets that exist already; `GET /v3/bank/connections/{id}/` opens
494
+ # today's budgets.
495
+ #
496
+ # +GET /v3/bank/connections/+
497
+ #
498
+ # @param status [String] Only connections in this status.
499
+ # @param access [String] Only this access mode.
500
+ # @param institution_id [String] Only this bank.
501
+ # @param country [String] Only banks in this country.
502
+ # @param vendor_data [String] Only connections with this `vendor_data`.
503
+ # @param end_user_reference [String] Only connections with this `end_user.reference`.
504
+ # @param consent_expires_before [Time, String] Only connections whose consent ends before this time, for example
505
+ # to send renew links.
506
+ # @param created_after [Time, String] Only connections created after this time.
507
+ # @param limit [Integer] Page size, 1 to 500. Default 100.
508
+ # @param cursor [String] Opaque cursor from the previous page's `next_cursor`.
509
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
510
+ # @return [Didit::Types::BankConnectionList]
511
+ def list_connections(
512
+ status: OMIT,
513
+ access: OMIT,
514
+ institution_id: OMIT,
515
+ country: OMIT,
516
+ vendor_data: OMIT,
517
+ end_user_reference: OMIT,
518
+ consent_expires_before: OMIT,
519
+ created_after: OMIT,
520
+ limit: OMIT,
521
+ cursor: OMIT,
522
+ request_options: nil
523
+ )
524
+ @client.request(
525
+ :get,
526
+ "/v3/bank/connections/",
527
+ query: {
528
+ "status" => status,
529
+ "access" => access,
530
+ "institution_id" => institution_id,
531
+ "country" => country,
532
+ "vendor_data" => vendor_data,
533
+ "end_user_reference" => end_user_reference,
534
+ "consent_expires_before" => consent_expires_before,
535
+ "created_after" => created_after,
536
+ "limit" => limit,
537
+ "cursor" => cursor
538
+ },
539
+ response: Types::BankConnectionList,
540
+ request_options: request_options
541
+ )
542
+ end
543
+
544
+ # List institutions
545
+ #
546
+ # Lists the banks per country with their capabilities: segments, access modes, the longest consent and deepest
547
+ # history the bank offers, whether it reports pending transactions, which transaction fields it is known to
548
+ # send, and how the person signs in. Values come from observed data, refreshed daily; a value never observed is
549
+ # `null`. The same data feeds the bank picker, so use it to know what to expect before you create a link.
550
+ # `access` lists `ongoing` only where ongoing access is available.
551
+ #
552
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
553
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
554
+ # bank_data_access_denied`.
555
+ #
556
+ # The list is sorted by name, then id.
557
+ #
558
+ # In a sandbox application the list holds the Didit Test Bank, one per country Bank Link serves, and no live
559
+ # bank.
560
+ #
561
+ # +GET /v3/bank/institutions/+
562
+ #
563
+ # @param country [String] Only banks in this country, an ISO 3166-1 alpha-3 code. A country Bank Link does not
564
+ # serve answers `400 invalid_request` with `field: country`.
565
+ # @param segment [String] Only banks that serve this segment.
566
+ # @param access [String] Only banks that offer this access mode.
567
+ # @param q [String] Search by name or id, case-insensitive.
568
+ # @param limit [Integer] Page size, 1 to 500. Default 100.
569
+ # @param cursor [String] Opaque cursor from the previous page's `next_cursor`.
570
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
571
+ # @return [Didit::Types::BankInstitutionList]
572
+ def list_institutions(
573
+ country: OMIT,
574
+ segment: OMIT,
575
+ access: OMIT,
576
+ q: OMIT,
577
+ limit: OMIT,
578
+ cursor: OMIT,
579
+ request_options: nil
580
+ )
581
+ @client.request(
582
+ :get,
583
+ "/v3/bank/institutions/",
584
+ query: {
585
+ "country" => country,
586
+ "segment" => segment,
587
+ "access" => access,
588
+ "q" => q,
589
+ "limit" => limit,
590
+ "cursor" => cursor
591
+ },
592
+ response: Types::BankInstitutionList,
593
+ request_options: request_options
594
+ )
595
+ end
596
+
597
+ # List sync runs
598
+ #
599
+ # Lists what each sync of a connection did, newest first, per account and resource.
600
+ #
601
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
602
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
603
+ # bank_data_access_denied`.
604
+ #
605
+ # +GET /v3/bank/connections/{id}/sync-runs/+
606
+ #
607
+ # @param id [String] The connection id.
608
+ # @param limit [Integer] Page size, 1 to 500. Default 100.
609
+ # @param cursor [String] Opaque cursor from the previous page's `next_cursor`.
610
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
611
+ # @return [Didit::Types::BankSyncRunList]
612
+ def list_sync_runs(id, limit: OMIT, cursor: OMIT, request_options: nil)
613
+ @client.request(
614
+ :get,
615
+ "/v3/bank/connections/{id}/sync-runs/",
616
+ path_params: { "id" => id },
617
+ query: {
618
+ "limit" => limit,
619
+ "cursor" => cursor
620
+ },
621
+ response: Types::BankSyncRunList,
622
+ request_options: request_options
623
+ )
624
+ end
625
+
626
+ # List account transactions
627
+ #
628
+ # Date-range read of an account's transactions, sorted by `effective_date` descending, then `id` descending, in
629
+ # pages of up to 500. `date_from` and `date_to` are calendar dates, inclusive, in the bank's own time zone with
630
+ # nothing converted. They apply to `effective_date`: for a booked transaction its booking date, else its value
631
+ # date, else the date it was first seen; for a pending one its transaction date, else the date it was first
632
+ # seen. By default `date_from` is the start of the stored history and `date_to` has no upper bound, and booked
633
+ # and pending are both returned.
634
+ #
635
+ # The first page pins which transactions are included and each is served in its current state: a transaction
636
+ # removed while you page drops out of later pages and is reported by the change feed (`sync_transactions`).
637
+ # `page_token` continues one read and lives one hour; an expired token answers `410 page_expired`, so restart
638
+ # the read from its original query. To keep a copy up to date, use the change feed instead of re-reading ranges.
639
+ #
640
+ # Response headers: `X-Bank-Last-Synced-At` and `Cache-Control: no-store`.
641
+ #
642
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
643
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
644
+ # bank_data_access_denied`. A sandbox application reads its Test Bank data with the key alone. A request without
645
+ # an API key (client credentials) is refused on raw data with the same `403`.
646
+ #
647
+ # +GET /v3/bank/accounts/{account_id}/transactions/+
648
+ #
649
+ # @param account_id [String] The account id.
650
+ # @param date_from [Date, String] First effective date to include, inclusive.
651
+ # @param date_to [Date, String] Last effective date to include, inclusive. No upper bound when you leave it out.
652
+ # @param status [String] Only booked or only pending transactions. Default both.
653
+ # @param limit [Integer] Page size, 1 to 500. Default 100.
654
+ # @param page_token [String] The `next_page_token` of the previous page.
655
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
656
+ # @return [Didit::Types::BankTransactionPage]
657
+ def list_transactions(
658
+ account_id,
659
+ date_from: OMIT,
660
+ date_to: OMIT,
661
+ status: OMIT,
662
+ limit: OMIT,
663
+ page_token: OMIT,
664
+ request_options: nil
665
+ )
666
+ @client.request(
667
+ :get,
668
+ "/v3/bank/accounts/{account_id}/transactions/",
669
+ path_params: { "account_id" => account_id },
670
+ query: {
671
+ "date_from" => date_from,
672
+ "date_to" => date_to,
673
+ "status" => status,
674
+ "limit" => limit,
675
+ "page_token" => page_token
676
+ },
677
+ response: Types::BankTransactionPage,
678
+ request_options: request_options
679
+ )
680
+ end
681
+
682
+ # Refresh a bank connection
683
+ #
684
+ # Syncs now: reads the bank for new data at any moment. Answers `202` with the `sync_id`; if a sync is already
685
+ # running you get that same `sync_id`, not a second job. With `"wait": true` in the body, or the header `Prefer:
686
+ # wait=<seconds>` (up to 25), the call holds for up to 25 seconds and answers `200` with the finished sync
687
+ # (`outcome`, the per-account counts and `balances_changed`), so one request returns fresh data. If the bank has
688
+ # not answered in that time it answers `202`: read the sync with `get_sync_run` using the `sync_id`, or
689
+ # subscribe to `bank.sync.completed`. `bank.data.updated` follows only when the sync stores changes.
690
+ #
691
+ # Live syncs are included in the monthly price of the connection, like the automatic syncs: nothing extra is
692
+ # charged. The only limit is the bank's. Banks limit reads without the person present, for example to four a day
693
+ # (the Didit Test Bank in sandbox does the same). The automatic syncs of the day (`sync.frequency_per_day`) are
694
+ # set aside first and the rest are yours, so `sync.budgets` shows what is left and `sync.live_syncs_left_today`
695
+ # how many live syncs remain today. The automatic schedule never uses the last two reads of a day, so two live
696
+ # syncs always remain. When the budget is used up the call answers `429 refresh_limit_reached` with
697
+ # `Retry-After` (the seconds until the budget resets, 1 to 86400) and a `sync` object with
698
+ # `live_syncs_left_today` and `budgets`. The limit is a ceiling set by the bank, not a promise of a number of
699
+ # syncs.
700
+ #
701
+ # When a sync stores changes, `bank.data.updated` tells you; then read the change feed.
702
+ #
703
+ # Needs an API key with the Bank data permission (`bank-data`): write for this operation, which changes
704
+ # something. A key with full access does not include it: grant it explicitly when you create the key, or the
705
+ # call answers `403 bank_data_access_denied`.
706
+ #
707
+ # Refreshing a deleted connection answers `409 connection_not_active`.
708
+ #
709
+ # +POST /v3/bank/connections/{id}/refresh/+
710
+ #
711
+ # @param id [String] The connection id.
712
+ # @param wait [Boolean] `true` holds the call for up to 25 seconds and answers `200` with the finished sync, so
713
+ # one request returns fresh data. If the bank has not answered in that time the call answers `202`: read the
714
+ # sync with `get_sync_run` using the `sync_id`, or subscribe to `bank.sync.completed`. `bank.data.updated`
715
+ # follows only when the sync stores changes. The header `Prefer: wait=<seconds>` (up to 25) does the...
716
+ # @param idempotency_key [String] sent as the Idempotency-Key header
717
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
718
+ # @return [Didit::Types::BankSyncCompleted, Didit::Types::BankRefreshAccepted]
719
+ def refresh_connection(id, wait: OMIT, idempotency_key: OMIT, request_options: nil)
720
+ @client.request(
721
+ :post,
722
+ "/v3/bank/connections/{id}/refresh/",
723
+ path_params: { "id" => id },
724
+ body: {
725
+ "wait" => wait
726
+ },
727
+ headers: { "Idempotency-Key" => idempotency_key },
728
+ response: { 200 => Types::BankSyncCompleted, 202 => Types::BankRefreshAccepted },
729
+ request_options: request_options
730
+ )
731
+ end
732
+
733
+ # Renew a bank connection
734
+ #
735
+ # Creates a renew link for this connection, a shortcut for `create_link` with `mode: renew`. The connection id
736
+ # and every account id stay the same.
737
+ #
738
+ # Opening the returned link on the hosted page is not available yet: the page that lets the person renew is
739
+ # still to be built.
740
+ #
741
+ # Until the consent has 30 days left or fewer it answers `409 renewal_not_needed`; after
742
+ # `consent.renewable_until` it answers `409 renewal_window_expired` and the person connects again.
743
+ #
744
+ # Needs an API key with the Bank data permission (`bank-data`): write for this operation, which changes
745
+ # something. A key with full access does not include it: grant it explicitly when you create the key, or the
746
+ # call answers `403 bank_data_access_denied`.
747
+ #
748
+ # +POST /v3/bank/connections/{id}/renew/+
749
+ #
750
+ # @param id [String] The connection id.
751
+ # @param redirect_url [String] Where the browser goes at the end. In a sandbox application a plain `http`
752
+ # address of `localhost`, `127.0.0.1` or `[::1]` needs no registration. Any other address answers `400
753
+ # redirect_url_not_registered`: registering other addresses is not available yet.
754
+ # @param allowed_origins [Array<String>] Accepted and not used today: reserved for Didit's embedded Bank Link,
755
+ # which is not released yet. HTTPS origins, up to 50.
756
+ # @param language [String]
757
+ # @param expires_in [Integer] Lifetime in seconds, 300 to 86400.
758
+ # @param idempotency_key [String] sent as the Idempotency-Key header
759
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
760
+ # @return [Didit::Types::BankLink]
761
+ def renew_connection(
762
+ id,
763
+ redirect_url: OMIT,
764
+ allowed_origins: OMIT,
765
+ language: OMIT,
766
+ expires_in: OMIT,
767
+ idempotency_key: OMIT,
768
+ request_options: nil
769
+ )
770
+ @client.request(
771
+ :post,
772
+ "/v3/bank/connections/{id}/renew/",
773
+ path_params: { "id" => id },
774
+ body: {
775
+ "redirect_url" => redirect_url,
776
+ "allowed_origins" => allowed_origins,
777
+ "language" => language,
778
+ "expires_in" => expires_in
779
+ },
780
+ headers: { "Idempotency-Key" => idempotency_key },
781
+ response: Types::BankLink,
782
+ request_options: request_options
783
+ )
784
+ end
785
+
786
+ # Revoke a bank connection
787
+ #
788
+ # Stops access to the bank. Bank fetches stop the moment you ask, even while the bank's confirmation is pending:
789
+ # the consent reads `revocation_pending`, then `revoked` once the bank confirms access is terminated, or
790
+ # `revocation_failed` while the call is retried automatically. `consent.ended_by` is `customer`.
791
+ #
792
+ # Revoking does not delete anything: stored accounts, balances and transactions stay readable until
793
+ # `consent.retain_until`, the retention setting of your application, and nothing is charged. To delete them now,
794
+ # call `delete_connection`. Repeating the call returns the current state.
795
+ #
796
+ # Needs an API key with the Bank data permission (`bank-data`): write for this operation, which changes
797
+ # something. A key with full access does not include it: grant it explicitly when you create the key, or the
798
+ # call answers `403 bank_data_access_denied`.
799
+ #
800
+ # Revoking a connection that was deleted answers `200` with the deleted connection, so repeating the call is
801
+ # safe.
802
+ #
803
+ # +POST /v3/bank/connections/{id}/revoke/+
804
+ #
805
+ # @param id [String] The connection id.
806
+ # @param idempotency_key [String] sent as the Idempotency-Key header
807
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
808
+ # @return [Didit::Types::BankConnection]
809
+ def revoke_connection(id, idempotency_key: OMIT, request_options: nil)
810
+ @client.request(
811
+ :post,
812
+ "/v3/bank/connections/{id}/revoke/",
813
+ path_params: { "id" => id },
814
+ headers: { "Idempotency-Key" => idempotency_key },
815
+ response: Types::BankConnection,
816
+ request_options: request_options
817
+ )
818
+ end
819
+
820
+ # Sync transactions (change feed)
821
+ #
822
+ # Returns what changed in a connection's transactions since a `cursor`: `added`, `modified` and `removed` (with
823
+ # a `reason`), across all its accounts. An empty cursor returns every current transaction as `added` and sets
824
+ # `reset: true`: replace your copy with it instead of adding to it.
825
+ #
826
+ # The first read is a true snapshot. A first read (no cursor, or the read after `reset`) returns every
827
+ # transaction the connection had when the read started, each exactly once as `added`, in its current state, even
828
+ # if a sync runs while you page. Changes made while you were paging arrive in the next read from `next_cursor`:
829
+ # a transaction you already received comes again as `modified`, and a new one as `added`. Apply `modified` as an
830
+ # upsert by `id`, and ignore a `removed` id you do not have. All pages of one read reflect the same point in
831
+ # time. Keep paging with `page_token` while `has_more` is `true`, and store `next_cursor` only after a response
832
+ # with `has_more: false`. If paging fails midway, restart from the cursor you had stored.
833
+ #
834
+ # The change log is replayable for 90 days. An older cursor answers `410 cursor_expired` with `bootstrap: true`:
835
+ # start again from an empty cursor. Stored history is never aged out while the connection exists. A booked
836
+ # pending transaction appears in `added` and the pending one in `removed` with `reason: pending_booked`. Webhook
837
+ # `bank.data.updated` tells you when to call.
838
+ #
839
+ # Needs an API key with the Bank data permission (`bank-data`): read for this operation. A key with full access
840
+ # does not include it: grant it explicitly when you create the key, or the call answers `403
841
+ # bank_data_access_denied`. A sandbox application reads its Test Bank data with the key alone. A request without
842
+ # an API key (client credentials) is refused on raw data with the same `403`.
843
+ #
844
+ # +GET /v3/bank/connections/{id}/transactions/sync/+
845
+ #
846
+ # @param id [String] The connection id.
847
+ # @param cursor [String] The `next_cursor` you stored. Empty or omitted starts from the beginning.
848
+ # @param limit [Integer] Page size, 1 to 500. Default 100.
849
+ # @param page_token [String] Continues the same read while `has_more` is `true`.
850
+ # @param request_options [Hash, nil] :timeout, :max_retries, :extra_headers, :extra_query, :extra_body
851
+ # @return [Didit::Types::BankTransactionChanges]
852
+ def sync_transactions(id, cursor: OMIT, limit: OMIT, page_token: OMIT, request_options: nil)
853
+ @client.request(
854
+ :get,
855
+ "/v3/bank/connections/{id}/transactions/sync/",
856
+ path_params: { "id" => id },
857
+ query: {
858
+ "cursor" => cursor,
859
+ "limit" => limit,
860
+ "page_token" => page_token
861
+ },
862
+ response: Types::BankTransactionChanges,
863
+ request_options: request_options
864
+ )
865
+ end
84
866
  end
85
867
  end
86
868
  end