fintoc 1.4.0 → 1.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 125043d067ac8281433e37d16a8376d3b25f581b3a4fc7f31b30e1b96623e570
4
- data.tar.gz: 909b347cacb35dfd8e495be517e7c6320ce8aa9930c592215651cd813636e256
3
+ metadata.gz: 34910f21240b0f76d808c9ab4f22b8ea4a904c9280b11e3bb1d39eee6660a0b6
4
+ data.tar.gz: ce6b1ca7100789cb27067aaeccd80324e089cbaf7b819317f35472f1fd3dad6d
5
5
  SHA512:
6
- metadata.gz: b4fe705e12286af83f27d6fbdae257f334f65b98122d16cb187b6d2c326b10c482356d30e4962faa2395e3e0199d83fc287b2d40a213cf8ff3f780eda714c7c7
7
- data.tar.gz: 8ff1d5bb3d658081d9dc3086ab8a2c0b01051c7cd5a30776a150960365191c33879016f5fb2738e63e15c9ca767adc1a5ee48c915f92b40837351c284f988312
6
+ metadata.gz: 963c67d86b28ec2a1215720a6ddc69ff102f2f4368bc32871167750418d49e0e1b46ad95ebb6406862be93bd80034ea9398eac3622b9ced2a8b13719c7f7a519
7
+ data.tar.gz: fb45a851b1ce805c9bfd31d9eeefb21646c0acccdff4e0a3be04e541e57778af090f553892127638ef2ebd623319c17c430f9a09168875fe1b94ec99392f25f5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fintoc (1.4.0)
4
+ fintoc (1.5.0)
5
5
  http
6
6
  money-rails
7
7
  tabulate
data/README.md CHANGED
@@ -31,6 +31,7 @@ Do yourself a favor: go grab some ice cubes by installing this refreshing librar
31
31
  - [Accounts](#accounts)
32
32
  - [Account Numbers](#account-numbers)
33
33
  - [Transfers](#transfers)
34
+ - [Transfer Batches](#transfer-batches)
34
35
  - [Simulate](#simulate)
35
36
  - [Account Verifications](#account-verifications)
36
37
  - [Entity onboardings API Examples](#entity-onboardings-api-examples)
@@ -139,6 +140,15 @@ transfer = client.v2.transfers.create(
139
140
  )
140
141
  client.v2.transfers.return('transfer_id')
141
142
 
143
+ # Transfer Batches
144
+ transfer_batches = client.v2.transfer_batches.list
145
+ transfer_batch = client.v2.transfer_batches.get('transfer_batch_id')
146
+ transfer_batch = client.v2.transfer_batches.create(
147
+ description: 'Supplier payments',
148
+ currency: 'MXN',
149
+ transfers: [{...}]
150
+ )
151
+
142
152
  # Simulate
143
153
  simulated_transfer = client.v2.simulate.receive_transfer(
144
154
  account_number_id: 'account_number_id',
@@ -360,6 +370,42 @@ transfers = client.v2.transfers.list
360
370
  returned_transfer = client.v2.transfers.return('transfer_id')
361
371
  ```
362
372
 
373
+ #### Transfer Batches
374
+
375
+ ```ruby
376
+ require 'fintoc'
377
+
378
+ client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
379
+
380
+ # Create a transfer batch. Each transfer has the same shape as `transfers.create`, without `currency`
381
+ transfer_batch = client.v2.transfer_batches.create(
382
+ description: 'Supplier payments',
383
+ currency: 'MXN',
384
+ transfers: [
385
+ {
386
+ account_id: 'account_id',
387
+ amount: 10000,
388
+ comment: 'Invoice 1234',
389
+ reference_id: '123456',
390
+ counterparty: { account_number: '735969000000203297' }
391
+ }
392
+ ]
393
+ )
394
+
395
+ # Get a specific transfer batch
396
+ transfer_batch = client.v2.transfer_batches.get('transfer_batch_id')
397
+
398
+ # List transfer batches, optionally filtered by status and creation date
399
+ transfer_batches = client.v2.transfer_batches.list(
400
+ 'status[]': %w[succeeded partially_succeeded],
401
+ since: '2026-10-01T00:00:00Z',
402
+ until: '2026-10-31T23:59:59Z'
403
+ )
404
+
405
+ # List the transfers of a batch
406
+ transfers = client.v2.transfers.list(transfer_batch_id: 'transfer_batch_id')
407
+ ```
408
+
363
409
  #### Simulate
364
410
 
365
411
  ```ruby
data/lib/fintoc/errors.rb CHANGED
@@ -66,6 +66,9 @@ module Fintoc
66
66
  class InvalidInstallmentsCurrencyError < FintocError; end
67
67
  class InvalidClabeError < FintocError; end
68
68
  class MismatchTransferAccountCurrencyError < FintocError; end
69
+ class InvalidTransfersError < FintocError; end
70
+ class InvalidTransfersSizeError < FintocError; end
71
+ class InvalidDescriptionSizeError < FintocError; end
69
72
 
70
73
  # 401 Unauthorized Errors
71
74
  class AuthenticationError < FintocError; end
@@ -124,6 +127,7 @@ module Fintoc
124
127
  class InvalidTransferDirectionError < FintocError; end
125
128
  class AccountNumberLimitReachedError < FintocError; end
126
129
  class AccountCannotBeBlockedError < FintocError; end
130
+ class InvalidSenderAccountsError < FintocError; end
127
131
 
128
132
  # 422 Unprocessable Entity Errors
129
133
  class InvalidOtpCodeError < FintocError; end
@@ -150,6 +154,9 @@ module Fintoc
150
154
  class UnrecognizedRequestError < FintocError; end
151
155
  class CoreResponseError < FintocError; end
152
156
 
157
+ # 501 Not Implemented Errors
158
+ class OperationNotImplementedError < FintocError; end
159
+
153
160
  # Webhook Errors
154
161
  class WebhookSignatureError < FintocError; end
155
162
 
@@ -3,6 +3,7 @@ require 'fintoc/v2/managers/entities_manager'
3
3
  require 'fintoc/v2/managers/accounts_manager'
4
4
  require 'fintoc/v2/managers/account_numbers_manager'
5
5
  require 'fintoc/v2/managers/transfers_manager'
6
+ require 'fintoc/v2/managers/transfer_batches_manager'
6
7
  require 'fintoc/v2/managers/simulate_manager'
7
8
  require 'fintoc/v2/managers/account_verifications_manager'
8
9
 
@@ -25,6 +26,10 @@ module Fintoc
25
26
  @transfers ||= Managers::TransfersManager.new(self)
26
27
  end
27
28
 
29
+ def transfer_batches
30
+ @transfer_batches ||= Managers::TransferBatchesManager.new(self)
31
+ end
32
+
28
33
  def simulate
29
34
  @simulate ||= Managers::SimulateManager.new(self)
30
35
  end
@@ -0,0 +1,47 @@
1
+ require 'fintoc/v2/resources/transfer_batch'
2
+
3
+ module Fintoc
4
+ module V2
5
+ module Managers
6
+ class TransferBatchesManager
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ def create(description:, currency:, transfers:, idempotency_key: nil)
12
+ data = _create_transfer_batch(description:, currency:, transfers:, idempotency_key:)
13
+ build_transfer_batch(data)
14
+ end
15
+
16
+ def get(transfer_batch_id)
17
+ data = _get_transfer_batch(transfer_batch_id)
18
+ build_transfer_batch(data)
19
+ end
20
+
21
+ def list(**params)
22
+ _list_transfer_batches(**params).map { |data| build_transfer_batch(data) }
23
+ end
24
+
25
+ private
26
+
27
+ def _create_transfer_batch(description:, currency:, transfers:, idempotency_key: nil)
28
+ @client
29
+ .post(version: :v2, use_jws: true, idempotency_key:)
30
+ .call('transfer_batches', description:, currency:, transfers:)
31
+ end
32
+
33
+ def _get_transfer_batch(transfer_batch_id)
34
+ @client.get(version: :v2).call("transfer_batches/#{transfer_batch_id}")
35
+ end
36
+
37
+ def _list_transfer_batches(**params)
38
+ @client.get(version: :v2).call('transfer_batches', **params)
39
+ end
40
+
41
+ def build_transfer_batch(data)
42
+ Fintoc::V2::TransferBatch.new(**data, client: @client)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,114 @@
1
+ require 'money'
2
+
3
+ module Fintoc
4
+ module V2
5
+ class TransferBatch
6
+ attr_reader :id, :object, :mode, :description, :status, :currency, :transfer_count,
7
+ :amount, :succeeded_count, :settled_amount, :created_at, :authorized_at,
8
+ :rejected_at, :expired_at, :succeeded_at, :partially_succeeded_at
9
+
10
+ def initialize( # rubocop:disable Metrics/MethodLength
11
+ id:,
12
+ object:,
13
+ mode:,
14
+ status:,
15
+ currency:,
16
+ transfer_count:,
17
+ amount:,
18
+ description: nil,
19
+ succeeded_count: nil,
20
+ settled_amount: nil,
21
+ created_at: nil,
22
+ authorized_at: nil,
23
+ rejected_at: nil,
24
+ expired_at: nil,
25
+ succeeded_at: nil,
26
+ partially_succeeded_at: nil,
27
+ client: nil,
28
+ **
29
+ )
30
+ @id = id
31
+ @object = object
32
+ @mode = mode
33
+ @description = description
34
+ @status = status
35
+ @currency = currency
36
+ @transfer_count = transfer_count
37
+ @amount = amount
38
+ @succeeded_count = succeeded_count
39
+ @settled_amount = settled_amount
40
+ @created_at = created_at
41
+ @authorized_at = authorized_at
42
+ @rejected_at = rejected_at
43
+ @expired_at = expired_at
44
+ @succeeded_at = succeeded_at
45
+ @partially_succeeded_at = partially_succeeded_at
46
+ @client = client
47
+ end
48
+
49
+ def to_s
50
+ amount_str = Money.from_cents(@amount, @currency).format
51
+ "📦 #{amount_str} (#{@id}) - #{@status}"
52
+ end
53
+
54
+ def refresh
55
+ fresh_transfer_batch = @client.transfer_batches.get(@id)
56
+ refresh_from_transfer_batch(fresh_transfer_batch)
57
+ end
58
+
59
+ def pending_authorization?
60
+ @status == 'pending_authorization'
61
+ end
62
+
63
+ def in_progress?
64
+ @status == 'in_progress'
65
+ end
66
+
67
+ def rejected?
68
+ @status == 'rejected'
69
+ end
70
+
71
+ def expired?
72
+ @status == 'expired'
73
+ end
74
+
75
+ def succeeded?
76
+ @status == 'succeeded'
77
+ end
78
+
79
+ def partially_succeeded?
80
+ @status == 'partially_succeeded'
81
+ end
82
+
83
+ def failed?
84
+ @status == 'failed'
85
+ end
86
+
87
+ private
88
+
89
+ def refresh_from_transfer_batch(transfer_batch) # rubocop:disable Metrics/MethodLength
90
+ unless transfer_batch.id == @id
91
+ raise ArgumentError, 'Transfer batch must be the same instance'
92
+ end
93
+
94
+ @object = transfer_batch.object
95
+ @mode = transfer_batch.mode
96
+ @description = transfer_batch.description
97
+ @status = transfer_batch.status
98
+ @currency = transfer_batch.currency
99
+ @transfer_count = transfer_batch.transfer_count
100
+ @amount = transfer_batch.amount
101
+ @succeeded_count = transfer_batch.succeeded_count
102
+ @settled_amount = transfer_batch.settled_amount
103
+ @created_at = transfer_batch.created_at
104
+ @authorized_at = transfer_batch.authorized_at
105
+ @rejected_at = transfer_batch.rejected_at
106
+ @expired_at = transfer_batch.expired_at
107
+ @succeeded_at = transfer_batch.succeeded_at
108
+ @partially_succeeded_at = transfer_batch.partially_succeeded_at
109
+
110
+ self
111
+ end
112
+ end
113
+ end
114
+ end
@@ -1,3 +1,3 @@
1
1
  module Fintoc
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fintoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Ca Sardin
@@ -101,6 +101,7 @@ files:
101
101
  - lib/fintoc/v2/managers/movements_manager.rb
102
102
  - lib/fintoc/v2/managers/onboardings_manager.rb
103
103
  - lib/fintoc/v2/managers/simulate_manager.rb
104
+ - lib/fintoc/v2/managers/transfer_batches_manager.rb
104
105
  - lib/fintoc/v2/managers/transfers_manager.rb
105
106
  - lib/fintoc/v2/resources/account.rb
106
107
  - lib/fintoc/v2/resources/account_number.rb
@@ -110,6 +111,7 @@ files:
110
111
  - lib/fintoc/v2/resources/movement.rb
111
112
  - lib/fintoc/v2/resources/onboarding.rb
112
113
  - lib/fintoc/v2/resources/transfer.rb
114
+ - lib/fintoc/v2/resources/transfer_batch.rb
113
115
  - lib/fintoc/version.rb
114
116
  - lib/fintoc/webhook_signature.rb
115
117
  - lib/tasks/simplecov_config.rb