fintoc 1.6.0 → 1.8.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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +117 -4
  4. data/fintoc.gemspec +3 -3
  5. data/lib/fintoc/base_client.rb +6 -4
  6. data/lib/fintoc/errors.rb +69 -0
  7. data/lib/fintoc/v1/client/client.rb +80 -0
  8. data/lib/fintoc/v1/managers/accounts_manager.rb +30 -0
  9. data/lib/fintoc/v1/managers/charges_manager.rb +48 -0
  10. data/lib/fintoc/v1/managers/disputes_manager.rb +43 -0
  11. data/lib/fintoc/v1/managers/institutions_manager.rb +19 -0
  12. data/lib/fintoc/v1/managers/invoices_manager.rb +30 -0
  13. data/lib/fintoc/v1/managers/link_intents_manager.rb +25 -0
  14. data/lib/fintoc/v1/managers/links_manager.rb +17 -0
  15. data/lib/fintoc/v1/managers/movements_manager.rb +31 -0
  16. data/lib/fintoc/v1/managers/payment_intents_manager.rb +42 -0
  17. data/lib/fintoc/v1/managers/payment_links_manager.rb +42 -0
  18. data/lib/fintoc/v1/managers/payouts_manager.rb +50 -0
  19. data/lib/fintoc/v1/managers/refresh_intents_manager.rb +39 -0
  20. data/lib/fintoc/v1/managers/refunds_manager.rb +47 -0
  21. data/lib/fintoc/v1/managers/subscription_intents_manager.rb +36 -0
  22. data/lib/fintoc/v1/managers/subscriptions_manager.rb +30 -0
  23. data/lib/fintoc/v1/managers/tax_returns_manager.rb +30 -0
  24. data/lib/fintoc/v1/managers/tax_statements_manager.rb +30 -0
  25. data/lib/fintoc/v1/managers/webhook_endpoints_manager.rb +1 -2
  26. data/lib/fintoc/v1/resources/account.rb +9 -2
  27. data/lib/fintoc/v1/resources/charge.rb +39 -0
  28. data/lib/fintoc/v1/resources/dispute.rb +41 -0
  29. data/lib/fintoc/v1/resources/dispute_document.rb +30 -0
  30. data/lib/fintoc/v1/resources/institution.rb +4 -2
  31. data/lib/fintoc/v1/resources/invoice.rb +43 -0
  32. data/lib/fintoc/v1/resources/link.rb +2 -2
  33. data/lib/fintoc/v1/resources/link_intent.rb +39 -0
  34. data/lib/fintoc/v1/resources/payment_intent.rb +72 -0
  35. data/lib/fintoc/v1/resources/payment_link.rb +43 -0
  36. data/lib/fintoc/v1/resources/payout.rb +37 -0
  37. data/lib/fintoc/v1/resources/refresh_intent.rb +37 -0
  38. data/lib/fintoc/v1/resources/refund.rb +43 -0
  39. data/lib/fintoc/v1/resources/subscription.rb +30 -0
  40. data/lib/fintoc/v1/resources/subscription_intent.rb +39 -0
  41. data/lib/fintoc/v1/resources/tax_return.rb +33 -0
  42. data/lib/fintoc/v1/resources/tax_statement.rb +39 -0
  43. data/lib/fintoc/v1/resources/webhook_endpoint.rb +10 -4
  44. data/lib/fintoc/v2/client/client.rb +45 -0
  45. data/lib/fintoc/v2/managers/account_verifications_manager.rb +4 -4
  46. data/lib/fintoc/v2/managers/checkout_sessions_manager.rb +42 -0
  47. data/lib/fintoc/v2/managers/customers_manager.rb +36 -0
  48. data/lib/fintoc/v2/managers/entities_manager.rb +6 -0
  49. data/lib/fintoc/v2/managers/events_manager.rb +30 -0
  50. data/lib/fintoc/v2/managers/invoice_lines_manager.rb +30 -0
  51. data/lib/fintoc/v2/managers/invoices_manager.rb +78 -0
  52. data/lib/fintoc/v2/managers/onboardings_manager.rb +14 -0
  53. data/lib/fintoc/v2/managers/payment_intents_manager.rb +53 -0
  54. data/lib/fintoc/v2/managers/payment_methods_manager.rb +68 -0
  55. data/lib/fintoc/v2/managers/products_manager.rb +42 -0
  56. data/lib/fintoc/v2/managers/setup_intents_manager.rb +24 -0
  57. data/lib/fintoc/v2/managers/subscription_items_manager.rb +41 -0
  58. data/lib/fintoc/v2/managers/subscriptions_manager.rb +54 -0
  59. data/lib/fintoc/v2/managers/transfers_manager.rb +4 -0
  60. data/lib/fintoc/v2/resources/checkout_session.rb +81 -0
  61. data/lib/fintoc/v2/resources/customer.rb +37 -0
  62. data/lib/fintoc/v2/resources/entity.rb +5 -1
  63. data/lib/fintoc/v2/resources/event.rb +28 -0
  64. data/lib/fintoc/v2/resources/invoice.rb +63 -0
  65. data/lib/fintoc/v2/resources/invoice_line.rb +35 -0
  66. data/lib/fintoc/v2/resources/payment_intent.rb +72 -0
  67. data/lib/fintoc/v2/resources/payment_method.rb +37 -0
  68. data/lib/fintoc/v2/resources/product.rb +32 -0
  69. data/lib/fintoc/v2/resources/settlement_account.rb +30 -0
  70. data/lib/fintoc/v2/resources/setup_intent.rb +24 -0
  71. data/lib/fintoc/v2/resources/subscription.rb +51 -0
  72. data/lib/fintoc/v2/resources/subscription_item.rb +24 -0
  73. data/lib/fintoc/version.rb +1 -1
  74. metadata +54 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18a0e42f4e865dc3c9a5effb821f75cd8c0df2fd1cc74d438b70cb25197db7c3
4
- data.tar.gz: d88a84f2581d693274770e4de27df625851116d896538f519eb4184f061e92aa
3
+ metadata.gz: 86cb95f11227365b5cc658916f6cf151503b495e07ecfb3f105cea3556b57a36
4
+ data.tar.gz: c50e35e79db4e944f7d930924be55211afe940130980f56470fb294a27f7fc4c
5
5
  SHA512:
6
- metadata.gz: 47a1a45fdd60049a311cc7aa6458c5942de82a4a2ae4a05139d3ebe92f96da5a2b8bdff7544d5195536575cc7fa209b54092cfaa3c5e0caf2a1e463b1389fed8
7
- data.tar.gz: 7e8677a9c72a33803a98c44ac8adedc86ed835d9bfa99505f8c17c9e8d77e0b8b6c41bbe1ad5681feefff7e88c995eb6a710b61ad8d573af29696777e13f3fe2
6
+ metadata.gz: 7ad5d6d2d7b5bfe4cb3adc3864c5671042b3085d703a3f01981e6088141f40f62ae17b4b837d957e596965d2a64f28fdf87a0f0aadbb9b5d415bb9d9f64e9019
7
+ data.tar.gz: cbae5df406a5a1f571fecb0aef8bd921985c31893fa79c1520641e6b49922b63996da581912db8aeb56cdf3f364f6004ff390bb4598e7ccd577cd8a32ed449e5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fintoc (1.6.0)
4
+ fintoc (1.8.0)
5
5
  http
6
6
  money-rails
7
7
  tabulate
data/README.md CHANGED
@@ -20,6 +20,7 @@ Do yourself a favor: go grab some ice cubes by installing this refreshing librar
20
20
  - [Client Architecture](#client-architecture)
21
21
  - [**API V1 Client**](#api-v1-client)
22
22
  - [**API V2 Client**](#api-v2-client)
23
+ - [**Pagination**](#pagination)
23
24
  - [**Backward compatibility**](#backward-compatibility)
24
25
  - [Documentation](#documentation)
25
26
  - [Examples](#examples)
@@ -92,7 +93,7 @@ The Fintoc Ruby client is organized into separate clients that mirror the offici
92
93
 
93
94
  ### **API V1 Client**
94
95
 
95
- The API client currently provides access to part of the Movements API:
96
+ The API V1 client provides access to the Movements, Payments and Webhooks APIs:
96
97
 
97
98
  ```ruby
98
99
  client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
@@ -100,15 +101,58 @@ client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
100
101
  # Link management
101
102
  links = client.v1.links.list
102
103
  link = client.v1.links.get('link_token')
104
+ link = client.v1.links.exchange(exchange_token: 'exchange_token')
105
+ client.v1.links.update('link_token', active: false)
103
106
  client.v1.links.delete('link_id')
107
+ link_intent = client.v1.link_intents.create(country: 'cl', holder_type: 'business', product: 'movements')
108
+ institutions = client.v1.institutions.list(country: 'cl')
104
109
 
105
110
  # Account access
106
111
  account = link.find(id: account_id)
112
+ accounts = client.v1.accounts.list(link_token: 'link_token')
113
+ account = client.v1.accounts.get('account_id', link_token: 'link_token')
114
+ movement = client.v1.movements.get('account_id', 'movement_id', link_token: 'link_token')
115
+
116
+ # Refresh intents
117
+ refresh_intent = client.v1.refresh_intents.create(link_token: 'link_token', refresh_type: 'only_last')
118
+ refresh_intents = client.v1.refresh_intents.list(link_token: 'link_token')
119
+
120
+ # Fiscal data (invoices, tax returns and tax statements) of a link
121
+ invoices = client.v1.invoices.list(link_token: 'link_token', since: '2026-01-01')
122
+ tax_return = client.v1.tax_returns.get('tax_return_id', link_token: 'link_token')
123
+ tax_statements = client.v1.tax_statements.list(link_token: 'link_token')
124
+
125
+ # Payment intents and payment links
126
+ payment_intent = client.v1.payment_intents.create(amount: 1000, currency: 'CLP')
127
+ client.v1.payment_intents.expire('payment_intent_id')
128
+ payment_link = client.v1.payment_links.create(amount: 1000, currency: 'CLP')
129
+ client.v1.payment_links.cancel('payment_link_id')
130
+
131
+ # Subscriptions and charges
132
+ subscription_intent = client.v1.subscription_intents.create(customer_email: 'payer@example.com')
133
+ subscriptions = client.v1.subscriptions.list
134
+ charge = client.v1.charges.create(amount: 1000, currency: 'CLP', subscription_id: 'sub_id')
135
+ client.v1.charges.update('charge_id', amount: 2000)
136
+ client.v1.charges.cancel('charge_id')
137
+
138
+ # Refunds
139
+ refund = client.v1.refunds.create(resource_id: 'pi_id', resource_type: 'payment_intent')
140
+ client.v1.refunds.cancel('refund_id')
141
+ voucher = client.v1.refunds.voucher_url('refund_id') # => { url: '...' }
142
+
143
+ # Payouts. `list_resources` returns payment intents, charges or refunds
144
+ payouts = client.v1.payouts.list(status: 'succeeded')
145
+ resources = client.v1.payouts.list_resources('payout_id', resource_type: 'payment_intent')
146
+
147
+ # Disputes
148
+ disputes = client.v1.disputes.list(status: 'needs_response')
149
+ client.v1.disputes.create_document('dispute_id', file: 'path/to/evidence.pdf')
150
+ client.v1.disputes.submit_for_review('dispute_id')
107
151
  ```
108
152
 
109
153
  ### **API V2 Client**
110
154
 
111
- The API V2 client currently provides access to part of the Transfers API:
155
+ The API V2 client provides access to the Transfers, Payments and Billing APIs:
112
156
 
113
157
  ```ruby
114
158
  client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
@@ -166,9 +210,64 @@ entity = client.v2.entities.get('entity_id')
166
210
  onboardings = entity.onboardings.list
167
211
  onboarding = entity.onboardings.get('onboarding_id')
168
212
 
169
- # TODO: Movements
213
+ # Settlement account of an entity
214
+ settlement_account = client.v2.entities.settlement_account('entity_id')
215
+
216
+ # Transfer receipts
217
+ receipt = client.v2.transfers.receipt('transfer_id') # => { download_url: '...', ... }
218
+
219
+ # Customers and payment methods
220
+ customer = client.v2.customers.create(email: 'customer@example.com', name: 'Jon Snow')
221
+ payment_methods = client.v2.payment_methods.list(customer: 'customer_id')
222
+ client.v2.payment_methods.cancel('payment_method_id')
223
+ mandate = client.v2.payment_methods.mandate_document('payment_method_id')
224
+ # Mexican direct debit mandates are sent as multipart. Nested fields are sent in
225
+ # bracket notation and consent documents accept a path or an IO.
226
+ payment_method = client.v2.payment_methods.create(
227
+ type: 'mx_direct_debit',
228
+ customer: 'customer_id',
229
+ mx_direct_debit: {
230
+ account_number: '000000000000000000',
231
+ account_type: 'clabe',
232
+ interval: 'month',
233
+ max_amount: 100000,
234
+ consent_documents: {
235
+ contract: 'contract.pdf', selfie: 'selfie.jpg', id_front: 'front.jpg', id_back: 'back.jpg'
236
+ }
237
+ }
238
+ )
239
+
240
+ # Payment intents, checkout sessions and setup intents
241
+ payment_intent = client.v2.payment_intents.create(
242
+ amount: 5000, currency: 'CLP', payment_method: 'payment_method_id'
243
+ )
244
+ client.v2.payment_intents.cancel('payment_intent_id')
245
+ eligibility = client.v2.payment_intents.check_eligibility(
246
+ amount: 5000, currency: 'CLP', sender_account: { institution_id: 'cl_banco_de_chile' }
247
+ )
248
+ checkout_session = client.v2.checkout_sessions.create(currency: 'CLP', flow: 'payment', amount: 5000)
249
+ client.v2.checkout_sessions.expire('checkout_session_id')
250
+ setup_intent = client.v2.setup_intents.get('setup_intent_id')
251
+
252
+ # Products, subscriptions and invoices
253
+ product = client.v2.products.create(name: 'Gym membership')
254
+ subscription = client.v2.subscriptions.create(customer: 'customer_id', items: [{...}])
255
+ subscription.subscription_items.create(price_data: {...}, quantity: 1)
256
+ client.v2.subscriptions.cancel('subscription_id')
257
+ invoice = client.v2.invoices.create(customer: 'customer_id', lines: [{...}])
258
+ client.v2.invoices.finalize('invoice_id')
259
+ client.v2.invoices.pay('invoice_id', external_payment: true)
260
+ invoice.invoice_lines.update('invoice_line_id', quantity: 2)
261
+
262
+ # Events
263
+ events = client.v2.events.list(type: 'payment_intent.succeeded')
264
+ event = client.v2.events.get('event_id')
170
265
  ```
171
266
 
267
+ ### **Pagination**
268
+
269
+ Manager `list` methods (`client.v1.*`, `client.v2.*`) return a single page. Pass the pagination params to fetch the next one: `page` and `per_page` in V1, and `limit` and `starting_after` in V2.
270
+
172
271
  ### **Backward compatibility**
173
272
 
174
273
  The methods of the previous `Fintoc::Client` class implementation are kept for backward compatibility purposes.
@@ -184,7 +283,7 @@ account = client.get_account('link_token', 'account_id')
184
283
 
185
284
  ## Documentation
186
285
 
187
- This client does not support all Fintoc API endpoints yet. For complete information about the API, head to the [docs](https://docs.fintoc.com/reference).
286
+ This client covers the public `v1` and `v2` endpoints of the Fintoc API. For complete information about the API, head to the [docs](https://docs.fintoc.com/reference).
188
287
 
189
288
  ## Examples
190
289
 
@@ -431,6 +530,14 @@ client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
431
530
  # Create an account verification
432
531
  account_verification = client.v2.account_verifications.create(account_number: 'account_number')
433
532
 
533
+ # Create an account verification for a Chilean account
534
+ account_verification = client.v2.account_verifications.create(
535
+ account_number: '000000001',
536
+ institution_id: 'cl_banco_de_chile',
537
+ account_type: 'checking_account',
538
+ holder_id: '11.111.111-1'
539
+ )
540
+
434
541
  # Get a specific account verification
435
542
  account_verification = client.v2.account_verifications.get('account_verification_id')
436
543
 
@@ -518,6 +625,12 @@ entity.onboardings.upload_legal_representative_document(
518
625
  'onboarding_id', 'legal_representative_id', 'identification', file: 'path/to/file.pdf'
519
626
  )
520
627
 
628
+ # Add another document to a slot that accepts several documents (multipart).
629
+ entity.onboardings.append_document('onboarding_id', 'slot_key', file: 'path/to/file.pdf')
630
+
631
+ # Delete a document from a slot.
632
+ entity.onboardings.delete_document('onboarding_id', 'slot_key', 'document_id')
633
+
521
634
  # Submit the onboarding for review.
522
635
  onboarding = entity.onboardings.submit('onboarding_id')
523
636
  ```
data/fintoc.gemspec CHANGED
@@ -18,10 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata['rubygems_mfa_required'] = 'true'
19
19
  # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
20
 
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{\A(?:(?:test|spec|features|\.agents|\.claude)/|(?:AGENTS|CLAUDE)\.md\z)})
24
+ end
25
25
  end
26
26
  spec.bindir = 'exe'
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -137,6 +137,8 @@ module Fintoc
137
137
 
138
138
  def build_form(form)
139
139
  form.transform_values do |value|
140
+ next value if value.is_a?(HTTP::FormData::Part)
141
+
140
142
  file?(value) ? HTTP::FormData::File.new(value) : value
141
143
  end
142
144
  end
@@ -150,12 +152,12 @@ module Fintoc
150
152
  end
151
153
 
152
154
  def error_class(snake_code)
153
- pascal_klass_name = Utils.snake_to_pascal(snake_code)
154
- # this conditional klass_name is to handle InternalServerError custom error class
155
- # without this the error class name would be like InternalServerErrorError (^-^)
155
+ pascal_klass_name = Utils.snake_to_pascal(snake_code.to_s)
156
156
  klass =
157
157
  pascal_klass_name.end_with?('Error') ? pascal_klass_name : "#{pascal_klass_name}Error"
158
- Module.const_get("Fintoc::Errors::#{klass}")
158
+ Fintoc::Errors.const_get(klass, false)
159
+ rescue NameError
160
+ Fintoc::Errors::FintocError
159
161
  end
160
162
 
161
163
  # rubocop:disable Layout/LineLength
data/lib/fintoc/errors.rb CHANGED
@@ -69,6 +69,21 @@ module Fintoc
69
69
  class InvalidTransfersError < FintocError; end
70
70
  class InvalidTransfersSizeError < FintocError; end
71
71
  class InvalidDescriptionSizeError < FintocError; end
72
+ class InvalidBillingCycleAnchorError < FintocError; end
73
+ class InvalidCountryCodeError < FintocError; end
74
+ class InvalidEmailError < FintocError; end
75
+ class InvalidInvoiceStatusError < FintocError; end
76
+ class InvalidMetadataError < FintocError; end
77
+ class InvalidPeriodError < FintocError; end
78
+ class InvalidReferenceIdFormatError < FintocError; end
79
+ class InvalidRefundToGetVoucherError < FintocError; end
80
+ class InvalidRutError < FintocError; end
81
+ class InvalidShareholderStructureError < FintocError; end
82
+ class InvalidWebhookEventTypeError < FintocError; end
83
+ class MinimumAmountError < FintocError; end
84
+ class MutuallyExclusiveParamsError < FintocError; end
85
+ class NotSupportedRefundableResourceTypeError < FintocError; end
86
+ class SplitSumMismatchError < FintocError; end
72
87
 
73
88
  # 401 Unauthorized Errors
74
89
  class AuthenticationError < FintocError; end
@@ -106,11 +121,14 @@ module Fintoc
106
121
  class MissingAllowedCidrBlocksError < FintocError; end
107
122
  class AllowedCidrBlocksDoesNotContainIpError < FintocError; end
108
123
  class RecipientBlockedAccountError < FintocError; end
124
+ class InvalidAccountVerificationError < FintocError; end
125
+ class PaymentMethodNotRefundableError < FintocError; end
109
126
 
110
127
  # 404 Not Found Errors
111
128
  class MissingResourceError < FintocError; end
112
129
  class InvalidUrlError < FintocError; end
113
130
  class OrganizationWithoutEntitiesError < FintocError; end
131
+ class ResourceNotFoundError < FintocError; end
114
132
 
115
133
  # 405 Method Not Allowed Errors
116
134
  class OperationNotAllowedError < FintocError; end
@@ -128,6 +146,23 @@ module Fintoc
128
146
  class AccountNumberLimitReachedError < FintocError; end
129
147
  class AccountCannotBeBlockedError < FintocError; end
130
148
  class InvalidSenderAccountsError < FintocError; end
149
+ class AccountNumberCouldNotBeAssignedError < FintocError; end
150
+ class AccountNumberTakenError < FintocError; end
151
+ class BlockedAccountNumberError < FintocError; end
152
+ class ConflictedRequestError < FintocError; end
153
+ class DisputeDeadlineExceededError < FintocError; end
154
+ class DisputeNotOpenForDocumentsError < FintocError; end
155
+ class DuplicateRecipientError < FintocError; end
156
+ class EntityHolderIdAlreadyExistsForOrganizationError < FintocError; end
157
+ class InvalidEmptySubscriptionError < FintocError; end
158
+ class InvoiceNotEditableError < FintocError; end
159
+ class InvoiceNotFinalizableError < FintocError; end
160
+ class InvoiceNotMarkableUncollectibleError < FintocError; end
161
+ class NoDocumentsToSubmitError < FintocError; end
162
+ class PaymentMethodNonCancelableError < FintocError; end
163
+ class PaymentNonCancelableError < FintocError; end
164
+ class PaymentNonExpirableError < FintocError; end
165
+ class SubscriptionNotEditableError < FintocError; end
131
166
 
132
167
  # 422 Unprocessable Entity Errors
133
168
  class InvalidOtpCodeError < FintocError; end
@@ -145,6 +180,40 @@ module Fintoc
145
180
  class RefreshIntentInProgressError < FintocError; end
146
181
  class RejectedRefreshIntentError < FintocError; end
147
182
  class SenderBlockedAccountError < FintocError; end
183
+ class AmountOutOfRangeError < FintocError; end
184
+ class CountryNotSupportedError < FintocError; end
185
+ class DirectDebitSuspendedError < FintocError; end
186
+ class FileTooLargeError < FintocError; end
187
+ class FileTooSmallError < FintocError; end
188
+ class InvalidAccountForDirectDebitError < FintocError; end
189
+ class InvalidPaymentMethodStateError < FintocError; end
190
+ class InvoiceHasPendingPaymentError < FintocError; end
191
+ class InvoiceNotPayableError < FintocError; end
192
+ class InvoiceNotVoidableError < FintocError; end
193
+ class LegalRepresentativeRequiredError < FintocError; end
194
+ class MandateLimitExceededError < FintocError; end
195
+ class MaximumAmountLimitError < FintocError; end
196
+ class MerchantChargeLimitExceededError < FintocError; end
197
+ class MerchantVolumeLimitExceededError < FintocError; end
198
+ class NotOneDayCompanyError < FintocError; end
199
+ class OnboardingImmutableError < FintocError; end
200
+ class OnboardingNotAvailableError < FintocError; end
201
+ class OrganizationWithoutOperationalRootEntityError < FintocError; end
202
+ class PaymentCancellationNotSupportedError < FintocError; end
203
+ class PaymentMethodInactiveError < FintocError; end
204
+ class PaymentMethodTypeNotAvailableError < FintocError; end
205
+ class PaymentMethodTypeNotSupportedError < FintocError; end
206
+ class PaymentMethodUnavailableError < FintocError; end
207
+ class RecipientAccountNotAllowedError < FintocError; end
208
+ class RequiredDocumentMissingError < FintocError; end
209
+ class RootEntityNotSupportedViaApiError < FintocError; end
210
+ class ShareholderDocumentNotRequiredError < FintocError; end
211
+ class SingleFileDocumentSlotError < FintocError; end
212
+ class SubscriptionCanceledError < FintocError; end
213
+ class UnknownDocumentSlotError < FintocError; end
214
+ class UnsupportedContentTypeError < FintocError; end
215
+ class UnsupportedInstitutionError < FintocError; end
216
+ class UnsupportedPaymentTypeError < FintocError; end
148
217
 
149
218
  # 429 Too Many Requests Errors
150
219
  class RateLimitExceededError < FintocError; end
@@ -1,6 +1,22 @@
1
1
  require 'fintoc/base_client'
2
2
  require 'fintoc/v1/managers/links_manager'
3
3
  require 'fintoc/v1/managers/webhook_endpoints_manager'
4
+ require 'fintoc/v1/managers/accounts_manager'
5
+ require 'fintoc/v1/managers/movements_manager'
6
+ require 'fintoc/v1/managers/institutions_manager'
7
+ require 'fintoc/v1/managers/link_intents_manager'
8
+ require 'fintoc/v1/managers/refresh_intents_manager'
9
+ require 'fintoc/v1/managers/tax_returns_manager'
10
+ require 'fintoc/v1/managers/tax_statements_manager'
11
+ require 'fintoc/v1/managers/invoices_manager'
12
+ require 'fintoc/v1/managers/payment_intents_manager'
13
+ require 'fintoc/v1/managers/payment_links_manager'
14
+ require 'fintoc/v1/managers/subscription_intents_manager'
15
+ require 'fintoc/v1/managers/subscriptions_manager'
16
+ require 'fintoc/v1/managers/charges_manager'
17
+ require 'fintoc/v1/managers/refunds_manager'
18
+ require 'fintoc/v1/managers/payouts_manager'
19
+ require 'fintoc/v1/managers/disputes_manager'
4
20
 
5
21
  module Fintoc
6
22
  module V1
@@ -12,6 +28,70 @@ module Fintoc
12
28
  def webhook_endpoints
13
29
  @webhook_endpoints ||= Managers::WebhookEndpointsManager.new(self)
14
30
  end
31
+
32
+ def accounts
33
+ @accounts ||= Managers::AccountsManager.new(self)
34
+ end
35
+
36
+ def movements
37
+ @movements ||= Managers::MovementsManager.new(self)
38
+ end
39
+
40
+ def institutions
41
+ @institutions ||= Managers::InstitutionsManager.new(self)
42
+ end
43
+
44
+ def link_intents
45
+ @link_intents ||= Managers::LinkIntentsManager.new(self)
46
+ end
47
+
48
+ def refresh_intents
49
+ @refresh_intents ||= Managers::RefreshIntentsManager.new(self)
50
+ end
51
+
52
+ def tax_returns
53
+ @tax_returns ||= Managers::TaxReturnsManager.new(self)
54
+ end
55
+
56
+ def tax_statements
57
+ @tax_statements ||= Managers::TaxStatementsManager.new(self)
58
+ end
59
+
60
+ def invoices
61
+ @invoices ||= Managers::InvoicesManager.new(self)
62
+ end
63
+
64
+ def payment_intents
65
+ @payment_intents ||= Managers::PaymentIntentsManager.new(self)
66
+ end
67
+
68
+ def payment_links
69
+ @payment_links ||= Managers::PaymentLinksManager.new(self)
70
+ end
71
+
72
+ def subscription_intents
73
+ @subscription_intents ||= Managers::SubscriptionIntentsManager.new(self)
74
+ end
75
+
76
+ def subscriptions
77
+ @subscriptions ||= Managers::SubscriptionsManager.new(self)
78
+ end
79
+
80
+ def charges
81
+ @charges ||= Managers::ChargesManager.new(self)
82
+ end
83
+
84
+ def refunds
85
+ @refunds ||= Managers::RefundsManager.new(self)
86
+ end
87
+
88
+ def payouts
89
+ @payouts ||= Managers::PayoutsManager.new(self)
90
+ end
91
+
92
+ def disputes
93
+ @disputes ||= Managers::DisputesManager.new(self)
94
+ end
15
95
  end
16
96
  end
17
97
  end
@@ -0,0 +1,30 @@
1
+ require 'fintoc/v1/resources/account'
2
+
3
+ module Fintoc
4
+ module V1
5
+ module Managers
6
+ class AccountsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def list(link_token:, **params)
12
+ @client.get(version: :v1).call('accounts', link_token:, **params).map do |data|
13
+ build_account(data, link_token)
14
+ end
15
+ end
16
+
17
+ def get(account_id, link_token:)
18
+ data = @client.get(version: :v1).call("accounts/#{account_id}", link_token:)
19
+ build_account(data, link_token)
20
+ end
21
+
22
+ private
23
+
24
+ def build_account(data, link_token)
25
+ Fintoc::V1::Account.new(**data, link_token:, client: @client)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,48 @@
1
+ require 'fintoc/v1/resources/charge'
2
+
3
+ module Fintoc
4
+ module V1
5
+ module Managers
6
+ class ChargesManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(amount:, currency:, subscription_id:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v1, idempotency_key:)
13
+ .call('charges', amount:, currency:, subscription_id:, **params)
14
+ build_charge(data)
15
+ end
16
+
17
+ def list(**params)
18
+ @client.get(version: :v1).call('charges', **params).map do |data|
19
+ build_charge(data)
20
+ end
21
+ end
22
+
23
+ def get(charge_id)
24
+ data = @client.get(version: :v1).call("charges/#{charge_id}")
25
+ build_charge(data)
26
+ end
27
+
28
+ def update(charge_id, idempotency_key: nil, **params)
29
+ data = @client.patch(version: :v1, idempotency_key:)
30
+ .call("charges/#{charge_id}", **params)
31
+ build_charge(data)
32
+ end
33
+
34
+ def cancel(charge_id, idempotency_key: nil)
35
+ data = @client.post(version: :v1, idempotency_key:)
36
+ .call("charges/#{charge_id}/cancel")
37
+ build_charge(data)
38
+ end
39
+
40
+ private
41
+
42
+ def build_charge(data)
43
+ Fintoc::V1::Charge.new(**data)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,43 @@
1
+ require 'fintoc/v1/resources/dispute'
2
+ require 'fintoc/v1/resources/dispute_document'
3
+
4
+ module Fintoc
5
+ module V1
6
+ module Managers
7
+ class DisputesManager
8
+ def initialize(client)
9
+ @client = client
10
+ end
11
+
12
+ def list(**params)
13
+ @client.get(version: :v1).call('disputes', **params).map do |data|
14
+ build_dispute(data)
15
+ end
16
+ end
17
+
18
+ def get(dispute_id)
19
+ data = @client.get(version: :v1).call("disputes/#{dispute_id}")
20
+ build_dispute(data)
21
+ end
22
+
23
+ def submit_for_review(dispute_id, idempotency_key: nil)
24
+ data = @client.post(version: :v1, idempotency_key:)
25
+ .call("disputes/#{dispute_id}/submit_for_review")
26
+ build_dispute(data)
27
+ end
28
+
29
+ def create_document(dispute_id, file:, idempotency_key: nil)
30
+ data = @client.post(version: :v1, idempotency_key:)
31
+ .call("disputes/#{dispute_id}/documents", form: { file: })
32
+ Fintoc::V1::DisputeDocument.new(**data)
33
+ end
34
+
35
+ private
36
+
37
+ def build_dispute(data)
38
+ Fintoc::V1::Dispute.new(**data)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,19 @@
1
+ require 'fintoc/v1/resources/institution'
2
+
3
+ module Fintoc
4
+ module V1
5
+ module Managers
6
+ class InstitutionsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def list(**params)
12
+ @client.get(version: :v1).call('institutions', **params).map do |data|
13
+ Fintoc::V1::Institution.new(**data)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ require 'fintoc/v1/resources/invoice'
2
+
3
+ module Fintoc
4
+ module V1
5
+ module Managers
6
+ class InvoicesManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def list(link_token:, **params)
12
+ @client.get(version: :v1).call('invoices', link_token:, **params).map do |data|
13
+ build_invoice(data)
14
+ end
15
+ end
16
+
17
+ def get(invoice_id, link_token:)
18
+ data = @client.get(version: :v1).call("invoices/#{invoice_id}", link_token:)
19
+ build_invoice(data)
20
+ end
21
+
22
+ private
23
+
24
+ def build_invoice(data)
25
+ Fintoc::V1::Invoice.new(**data)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ require 'fintoc/v1/resources/link_intent'
2
+
3
+ module Fintoc
4
+ module V1
5
+ module Managers
6
+ class LinkIntentsManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(country:, holder_type:, product:, idempotency_key: nil, **params)
12
+ data = @client.post(version: :v1, idempotency_key:)
13
+ .call('link_intents', country:, holder_type:, product:, **params)
14
+ build_link_intent(data)
15
+ end
16
+
17
+ private
18
+
19
+ def build_link_intent(data)
20
+ Fintoc::V1::LinkIntent.new(**data)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -21,6 +21,15 @@ module Fintoc
21
21
  _delete_link(link_id)
22
22
  end
23
23
 
24
+ def update(link_token, idempotency_key: nil, **params)
25
+ data = { **_update_link(link_token, idempotency_key:, **params), link_token: link_token }
26
+ build_link(data)
27
+ end
28
+
29
+ def exchange(exchange_token:)
30
+ build_link(_exchange_link(exchange_token))
31
+ end
32
+
24
33
  private
25
34
 
26
35
  def _get_link(link_token)
@@ -35,6 +44,14 @@ module Fintoc
35
44
  @client.delete(version: :v1).call("links/#{link_id}")
36
45
  end
37
46
 
47
+ def _update_link(link_token, idempotency_key: nil, **params)
48
+ @client.patch(version: :v1, idempotency_key:).call("links/#{link_token}", **params)
49
+ end
50
+
51
+ def _exchange_link(exchange_token)
52
+ @client.get(version: :v1).call('links/exchange', exchange_token:)
53
+ end
54
+
38
55
  def build_link(data)
39
56
  param = Utils.pick(data, 'link_token')
40
57
  @client.default_params.update(param)