fintoc 0.1.0 → 1.1.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 +4 -4
- data/.github/pull_request_template.md +46 -0
- data/.github/workflows/ci.yml +46 -0
- data/.rubocop.yml +14 -7
- data/CHANGELOG.md +53 -1
- data/Gemfile +20 -1
- data/Gemfile.lock +237 -61
- data/README.md +404 -42
- data/Rakefile +3 -3
- data/fintoc.gemspec +3 -7
- data/lib/config/initializers/money.rb +5 -0
- data/lib/fintoc/base_client.rb +161 -0
- data/lib/fintoc/client.rb +14 -123
- data/lib/fintoc/constants.rb +4 -3
- data/lib/fintoc/errors.rb +139 -15
- data/lib/fintoc/jws.rb +83 -0
- data/lib/fintoc/utils.rb +2 -2
- data/lib/fintoc/v1/client/client.rb +12 -0
- data/lib/fintoc/v1/managers/links_manager.rb +46 -0
- data/lib/fintoc/v1/resources/account.rb +95 -0
- data/lib/fintoc/v1/resources/balance.rb +27 -0
- data/lib/fintoc/v1/resources/institution.rb +21 -0
- data/lib/fintoc/v1/resources/link.rb +85 -0
- data/lib/fintoc/v1/resources/movement.rb +62 -0
- data/lib/fintoc/v1/resources/transfer_account.rb +24 -0
- data/lib/fintoc/v2/client/client.rb +37 -0
- data/lib/fintoc/v2/managers/account_numbers_manager.rb +64 -0
- data/lib/fintoc/v2/managers/account_verifications_manager.rb +46 -0
- data/lib/fintoc/v2/managers/accounts_manager.rb +55 -0
- data/lib/fintoc/v2/managers/entities_manager.rb +36 -0
- data/lib/fintoc/v2/managers/simulate_manager.rb +32 -0
- data/lib/fintoc/v2/managers/transfers_manager.rb +61 -0
- data/lib/fintoc/v2/resources/account.rb +106 -0
- data/lib/fintoc/v2/resources/account_number.rb +106 -0
- data/lib/fintoc/v2/resources/account_verification.rb +73 -0
- data/lib/fintoc/v2/resources/entity.rb +51 -0
- data/lib/fintoc/v2/resources/transfer.rb +131 -0
- data/lib/fintoc/version.rb +1 -1
- data/lib/fintoc/webhook_signature.rb +73 -0
- data/lib/fintoc.rb +3 -0
- data/lib/tasks/simplecov_config.rb +19 -0
- metadata +35 -83
- data/lib/fintoc/resources/account.rb +0 -84
- data/lib/fintoc/resources/balance.rb +0 -24
- data/lib/fintoc/resources/institution.rb +0 -18
- data/lib/fintoc/resources/link.rb +0 -83
- data/lib/fintoc/resources/movement.rb +0 -55
- data/lib/fintoc/resources/transfer_account.rb +0 -22
data/README.md
CHANGED
@@ -13,18 +13,38 @@ Do yourself a favor: go grab some ice cubes by installing this refreshing librar
|
|
13
13
|
## Table of contents
|
14
14
|
|
15
15
|
- [Fintoc meets Ruby](#fintoc-meets-ruby)
|
16
|
+
- [Why?](#why)
|
16
17
|
- [Table of contents](#table-of-contents)
|
17
|
-
- [How to
|
18
|
+
- [How to Install](#how-to-install)
|
18
19
|
- [Quickstart](#quickstart)
|
20
|
+
- [Client Architecture](#client-architecture)
|
21
|
+
- [**API V1 Client**](#api-v1-client)
|
22
|
+
- [**API V2 Client**](#api-v2-client)
|
23
|
+
- [**Backward compatibility**](#backward-compatibility)
|
19
24
|
- [Documentation](#documentation)
|
20
25
|
- [Examples](#examples)
|
21
|
-
- [
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
- [Movements API Examples](#movements-api-examples)
|
27
|
+
- [Get accounts](#get-accounts)
|
28
|
+
- [Get movements](#get-movements)
|
29
|
+
- [Transfers API Examples](#transfers-api-examples)
|
30
|
+
- [Entities](#entities)
|
31
|
+
- [Accounts](#accounts)
|
32
|
+
- [Account Numbers](#account-numbers)
|
33
|
+
- [Transfers](#transfers)
|
34
|
+
- [Simulate](#simulate)
|
35
|
+
- [Account Verifications](#account-verifications)
|
36
|
+
- [Idempotency Keys](#idempotency-keys)
|
37
|
+
- [Idempotency Examples](#idempotency-examples)
|
38
|
+
- [Account Methods with Idempotency Key](#account-methods-with-idempotency-key)
|
39
|
+
- [Account Number Methods with Idempotency Key](#account-number-methods-with-idempotency-key)
|
40
|
+
- [Transfer Methods with Idempotency Key](#transfer-methods-with-idempotency-key)
|
41
|
+
- [Simulation with Idempotency Key](#simulation-with-idempotency-key)
|
42
|
+
- [Account Verification with Idempotency Key](#account-verification-with-idempotency-key)
|
43
|
+
- [About idempotency keys](#about-idempotency-keys)
|
44
|
+
- [Development](#development)
|
45
|
+
- [Dependencies](#dependencies)
|
46
|
+
- [Setup](#setup)
|
47
|
+
- [Contributing](#contributing)
|
28
48
|
|
29
49
|
## How to Install
|
30
50
|
|
@@ -36,11 +56,11 @@ gem 'fintoc'
|
|
36
56
|
|
37
57
|
And then execute:
|
38
58
|
|
39
|
-
|
59
|
+
$ bundle install
|
40
60
|
|
41
61
|
Or install it yourself as:
|
42
62
|
|
43
|
-
|
63
|
+
$ gem install fintoc
|
44
64
|
|
45
65
|
## Quickstart
|
46
66
|
|
@@ -51,37 +71,121 @@ Or install it yourself as:
|
|
51
71
|
```ruby
|
52
72
|
require 'fintoc'
|
53
73
|
|
54
|
-
client = Fintoc::Client.new('
|
55
|
-
link = client.
|
74
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
75
|
+
link = client.v1.links.get('link_token')
|
56
76
|
account = link.find(type: 'checking_account')
|
57
77
|
|
58
|
-
# Get the
|
59
|
-
movements = account.
|
78
|
+
# Get the last 30 movements
|
79
|
+
movements = account.movements.list
|
60
80
|
|
61
81
|
# Or get all the movements since a specific date
|
62
|
-
movements = account.
|
63
|
-
|
82
|
+
movements = account.movements.list(since: '2020-08-15')
|
64
83
|
```
|
84
|
+
|
65
85
|
And that’s it!
|
66
86
|
|
87
|
+
## Client Architecture
|
88
|
+
|
89
|
+
The Fintoc Ruby client is organized into separate clients that mirror the official API structure:
|
90
|
+
|
91
|
+
### **API V1 Client**
|
92
|
+
|
93
|
+
The API client currently provides access to part of the Movements API:
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
97
|
+
|
98
|
+
# Link management
|
99
|
+
links = client.v1.links.list
|
100
|
+
link = client.v1.links.get('link_token')
|
101
|
+
client.v1.links.delete('link_id')
|
102
|
+
|
103
|
+
# Account access
|
104
|
+
account = link.find(id: account_id)
|
105
|
+
```
|
106
|
+
|
107
|
+
### **API V2 Client**
|
108
|
+
|
109
|
+
The API V2 client currently provides access to part of the Transfers API:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
113
|
+
|
114
|
+
# Entities
|
115
|
+
entities = client.v2.entities.list
|
116
|
+
entity = client.v2.entities.get('entity_id')
|
117
|
+
|
118
|
+
# Accounts
|
119
|
+
accounts = client.v2.accounts.list
|
120
|
+
account = client.v2.accounts.get('account_id')
|
121
|
+
account = client.v2.accounts.create(entity_id: 'entity_id', description: 'My Account')
|
122
|
+
client.v2.accounts.update('account_id', description: 'Updated')
|
123
|
+
|
124
|
+
# Account Numbers
|
125
|
+
account_numbers = client.v2.account_numbers.list
|
126
|
+
account_number = client.v2.account_numbers.get('account_number_id')
|
127
|
+
account_number = client.v2.account_numbers.create(account_id: 'account_id', description: 'Main')
|
128
|
+
client.v2.account_numbers.update('account_number_id', description: 'Updated')
|
129
|
+
|
130
|
+
# Transfers
|
131
|
+
transfers = client.v2.transfers.list
|
132
|
+
transfer = client.v2.transfers.get('transfer_id')
|
133
|
+
transfer = client.v2.transfers.create(
|
134
|
+
amount: 1000,
|
135
|
+
currency: 'CLP',
|
136
|
+
account_id: 'account_id',
|
137
|
+
counterparty: {...}
|
138
|
+
)
|
139
|
+
client.v2.transfers.return('transfer_id')
|
140
|
+
|
141
|
+
# Simulate
|
142
|
+
simulated_transfer = client.v2.simulate.receive_transfer(
|
143
|
+
account_number_id: 'account_number_id',
|
144
|
+
amount: 1000,
|
145
|
+
currency: 'CLP'
|
146
|
+
)
|
147
|
+
|
148
|
+
# Account Verifications
|
149
|
+
account_verifications = client.v2.account_verifications.list
|
150
|
+
account_verification = client.v2.account_verifications.get('account_verification_id')
|
151
|
+
account_verification = client.v2.account_verifications.create(account_number: 'account_number')
|
152
|
+
|
153
|
+
# TODO: Movements
|
154
|
+
```
|
155
|
+
|
156
|
+
### **Backward compatibility**
|
157
|
+
|
158
|
+
The methods of the previous `Fintoc::Client` class implementation are kept for backward compatibility purposes.
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
162
|
+
|
163
|
+
link = client.get_link('link_token')
|
164
|
+
links = client.get_links
|
165
|
+
client.delete_link(link.id)
|
166
|
+
account = client.get_account('link_token', 'account_id')
|
167
|
+
```
|
168
|
+
|
67
169
|
## Documentation
|
68
170
|
|
69
|
-
This client
|
171
|
+
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).
|
70
172
|
|
71
173
|
## Examples
|
72
174
|
|
73
|
-
###
|
175
|
+
### Movements API Examples
|
176
|
+
|
177
|
+
#### Get accounts
|
74
178
|
|
75
179
|
```ruby
|
76
180
|
require 'fintoc'
|
77
181
|
|
78
|
-
client = Fintoc::Client.new('api_key')
|
79
|
-
link = client.
|
182
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
183
|
+
link = client.v1.links.get('link_token')
|
80
184
|
puts link.accounts
|
81
185
|
|
82
186
|
# Or... you can pretty print all the accounts in a Link
|
83
187
|
|
84
|
-
link = client.
|
188
|
+
link = client.v1.links.get('link_token')
|
85
189
|
link.show_accounts
|
86
190
|
|
87
191
|
```
|
@@ -91,8 +195,8 @@ If you want to find a specific account in a link, you can use **find**. You can
|
|
91
195
|
```ruby
|
92
196
|
require 'fintoc'
|
93
197
|
|
94
|
-
client = Fintoc::Client.new('api_key')
|
95
|
-
link = client.
|
198
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
199
|
+
link = client.v1.links.get('link_token')
|
96
200
|
account = link.find(type: 'checking_account')
|
97
201
|
|
98
202
|
# Or by number
|
@@ -107,8 +211,8 @@ You can also search for multiple accounts matching a specific criteria with **fi
|
|
107
211
|
```ruby
|
108
212
|
require 'fintoc'
|
109
213
|
|
110
|
-
client = Fintoc::Client.new('api_key')
|
111
|
-
link = client.
|
214
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
215
|
+
link = client.v1.links.get('link_token')
|
112
216
|
accounts = link.find_all(currency: 'CLP')
|
113
217
|
```
|
114
218
|
|
@@ -117,50 +221,308 @@ To update the account balance you can use **update_balance**:
|
|
117
221
|
```ruby
|
118
222
|
require 'fintoc'
|
119
223
|
|
120
|
-
client = Fintoc::Client.new('api_key')
|
121
|
-
link = client.
|
224
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
225
|
+
link = client.v1.links.get('link_token')
|
122
226
|
account = link.find(number: '1111111')
|
123
227
|
account.update_balance
|
124
228
|
```
|
125
229
|
|
126
|
-
|
230
|
+
#### Get movements
|
127
231
|
|
128
232
|
```ruby
|
129
233
|
require 'fintoc'
|
130
234
|
require 'time'
|
131
235
|
|
132
|
-
client = Fintoc::Client.new('api_key')
|
133
|
-
link = client.
|
236
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
237
|
+
link = client.v1.links.get('link_token')
|
134
238
|
account = link.find(type: 'checking_account')
|
135
239
|
|
136
240
|
# You can get the account movements since a specific DateTime
|
137
241
|
yesterday = DateTime.now - 1
|
138
|
-
account.
|
242
|
+
account.movements.list(since: yesterday)
|
139
243
|
|
140
244
|
# Or you can use an ISO 8601 formatted string representation of the Date
|
141
|
-
account.
|
245
|
+
account.movements.list(since: '2020-01-01')
|
142
246
|
|
143
247
|
# You can also set how many movements you want per_page
|
144
|
-
account.
|
248
|
+
account.movements.list(since: '2020-01-01', per_page: 100)
|
249
|
+
```
|
250
|
+
|
251
|
+
Calling **movements.list** without arguments gets the last 30 movements of the account
|
252
|
+
|
253
|
+
### Transfers API Examples
|
254
|
+
|
255
|
+
#### Entities
|
256
|
+
|
257
|
+
```ruby
|
258
|
+
require 'fintoc'
|
259
|
+
|
260
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
261
|
+
|
262
|
+
# Get all entities
|
263
|
+
entities = client.v2.entities.list
|
264
|
+
|
265
|
+
# Get a specific entity
|
266
|
+
entity = client.v2.entities.get('entity_id')
|
267
|
+
```
|
268
|
+
|
269
|
+
You can also list entities with pagination:
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
# Get entities with pagination
|
273
|
+
entities = client.v2.entities.list(limit: 10, starting_after: 'entity_id')
|
274
|
+
```
|
275
|
+
|
276
|
+
#### Accounts
|
277
|
+
|
278
|
+
```ruby
|
279
|
+
require 'fintoc'
|
280
|
+
|
281
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
282
|
+
|
283
|
+
# Create an account
|
284
|
+
account = client.v2.accounts.create(
|
285
|
+
entity_id: 'entity_id',
|
286
|
+
description: 'My Business Account'
|
287
|
+
)
|
288
|
+
|
289
|
+
# Get a specific account
|
290
|
+
account = client.v2.accounts.get('account_id')
|
291
|
+
|
292
|
+
# List all accounts
|
293
|
+
accounts = client.v2.accounts.list
|
294
|
+
|
295
|
+
# Update an account
|
296
|
+
updated_account = client.v2.accounts.update('account_id', description: 'Updated Description')
|
297
|
+
```
|
298
|
+
|
299
|
+
#### Account Numbers
|
300
|
+
|
301
|
+
```ruby
|
302
|
+
require 'fintoc'
|
303
|
+
|
304
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
305
|
+
|
306
|
+
# Create an account number
|
307
|
+
account_number = client.v2.account_numbers.create(
|
308
|
+
account_id: 'account_id',
|
309
|
+
description: 'Main account number'
|
310
|
+
)
|
311
|
+
|
312
|
+
# Get a specific account number
|
313
|
+
account_number = client.v2.account_numbers.get('account_number_id')
|
314
|
+
|
315
|
+
# List all account numbers
|
316
|
+
account_numbers = client.v2.account_numbers.list
|
317
|
+
|
318
|
+
# Update an account number
|
319
|
+
updated_account_number = client.v2.account_numbers.update(
|
320
|
+
'account_number_id',
|
321
|
+
description: 'Updated account number'
|
322
|
+
)
|
323
|
+
```
|
324
|
+
|
325
|
+
#### Transfers
|
326
|
+
|
327
|
+
```ruby
|
328
|
+
require 'fintoc'
|
329
|
+
|
330
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
331
|
+
|
332
|
+
# Create a transfer
|
333
|
+
transfer = client.v2.transfers.create(
|
334
|
+
amount: 10000,
|
335
|
+
currency: 'CLP',
|
336
|
+
account_id: 'account_id',
|
337
|
+
counterparty: {
|
338
|
+
name: 'John Doe',
|
339
|
+
rut: '12345678-9',
|
340
|
+
email: 'john@example.com',
|
341
|
+
bank: 'banco_de_chile',
|
342
|
+
account_type: 'checking_account',
|
343
|
+
account_number: '1234567890'
|
344
|
+
}
|
345
|
+
)
|
346
|
+
|
347
|
+
# Get a specific transfer
|
348
|
+
transfer = client.v2.transfers.get('transfer_id')
|
349
|
+
|
350
|
+
# List all transfers
|
351
|
+
transfers = client.v2.transfers.list
|
352
|
+
|
353
|
+
# Return a transfer
|
354
|
+
returned_transfer = client.v2.transfers.return('transfer_id')
|
355
|
+
```
|
356
|
+
|
357
|
+
#### Simulate
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
require 'fintoc'
|
361
|
+
|
362
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
363
|
+
|
364
|
+
# Simulate receiving a transfer
|
365
|
+
simulated_transfer = client.v2.simulate.receive_transfer(
|
366
|
+
account_number_id: 'account_number_id',
|
367
|
+
amount: 5000,
|
368
|
+
currency: 'CLP'
|
369
|
+
)
|
370
|
+
```
|
371
|
+
|
372
|
+
#### Account Verifications
|
373
|
+
|
374
|
+
```ruby
|
375
|
+
require 'fintoc'
|
376
|
+
|
377
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
378
|
+
|
379
|
+
# Create an account verification
|
380
|
+
account_verification = client.v2.account_verifications.create(account_number: 'account_number')
|
381
|
+
|
382
|
+
# Get a specific account verification
|
383
|
+
account_verification = client.v2.account_verifications.get('account_verification_id')
|
384
|
+
|
385
|
+
# List all account verifications
|
386
|
+
account_verifications = client.v2.account_verifications.list
|
387
|
+
```
|
388
|
+
|
389
|
+
## Idempotency Keys
|
390
|
+
|
391
|
+
The Fintoc API supports [idempotency](https://docs.fintoc.com/reference/idempotent-requests) for safely retrying requests without accidentally performing the same operation twice. This is particularly useful when creating transfers, account numbers, accounts, or other resources where you want to avoid duplicates due to network issues.
|
392
|
+
|
393
|
+
To use idempotency keys, provide an `idempotency_key` parameter when making POST/PATCH requests:
|
394
|
+
|
395
|
+
### Idempotency Examples
|
396
|
+
|
397
|
+
#### Account Methods with Idempotency Key
|
398
|
+
|
399
|
+
Create and update methods support the use of idempotency keys to prevent duplication:
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
require 'fintoc'
|
403
|
+
require 'securerandom'
|
404
|
+
|
405
|
+
client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key')
|
406
|
+
|
407
|
+
idempotency_key = SecureRandom.uuid
|
408
|
+
account = client.v2.accounts.create(
|
409
|
+
entity_id: 'entity_id', description: 'My Business Account', idempotency_key:
|
410
|
+
)
|
411
|
+
|
412
|
+
idempotency_key = SecureRandom.uuid
|
413
|
+
updated_account = client.v2.accounts.update(
|
414
|
+
'account_id', description: 'Updated Description', idempotency_key:
|
415
|
+
)
|
416
|
+
```
|
417
|
+
|
418
|
+
Simulation of transfers can also be done with idempotency key:
|
419
|
+
|
420
|
+
```ruby
|
421
|
+
idempotency_key = SecureRandom.uuid
|
422
|
+
account.simulate_receive_transfer(amount: 1000, idempotency_key:)
|
423
|
+
```
|
424
|
+
|
425
|
+
#### Account Number Methods with Idempotency Key
|
426
|
+
|
427
|
+
Create and update methods support the use of idempotency keys as well:
|
428
|
+
|
429
|
+
```ruby
|
430
|
+
idempotency_key = SecureRandom.uuid
|
431
|
+
account_number = client.v2.account_numbers.create(
|
432
|
+
account_id: 'account_id', description: 'Main account number', idempotency_key:
|
433
|
+
)
|
434
|
+
|
435
|
+
idempotency_key = SecureRandom.uuid
|
436
|
+
updated_account_number = client.v2.account_numbers.update(
|
437
|
+
'account_number_id', description: 'Updated description', idempotency_key:
|
438
|
+
)
|
439
|
+
```
|
440
|
+
|
441
|
+
Simulation of transfers can also be done with idempotency key:
|
442
|
+
|
443
|
+
```ruby
|
444
|
+
account_number.simulate_receive_transfer(amount: 1000, currency: 'MXN', idempotency_key:)
|
445
|
+
```
|
446
|
+
|
447
|
+
#### Transfer Methods with Idempotency Key
|
448
|
+
|
449
|
+
Creating and returning transfers support the use of idempotency keys:
|
450
|
+
|
451
|
+
```ruby
|
452
|
+
idempotency_key = SecureRandom.uuid
|
453
|
+
transfer = client.v2.transfers.create(
|
454
|
+
amount: 10000, currency: 'CLP', account_id: 'account_id', counterparty: { ... }, idempotency_key:
|
455
|
+
)
|
456
|
+
|
457
|
+
idempotency_key = SecureRandom.uuid
|
458
|
+
returned_transfer = client.v2.transfers.return('transfer_id', idempotency_key:)
|
145
459
|
```
|
146
460
|
|
147
|
-
|
461
|
+
Returning a transfer as an instance method also supports the use of idempotency key:
|
148
462
|
|
149
|
-
|
463
|
+
```ruby
|
464
|
+
idempotency_key = SecureRandom.uuid
|
465
|
+
transfer.return_transfer(idempotency_key:)
|
466
|
+
```
|
150
467
|
|
151
|
-
|
468
|
+
#### Simulation with Idempotency Key
|
152
469
|
|
153
|
-
|
154
|
-
- [**tabulate**](https://github.com/roylez/tabulate)
|
470
|
+
For simulating transfers, the use of idempotency keys is also supported:
|
155
471
|
|
156
|
-
|
472
|
+
```ruby
|
473
|
+
idempotency_key = SecureRandom.uuid
|
474
|
+
simulated_transfer = client.v2.simulate.receive_transfer(
|
475
|
+
account_number_id: 'account_number_id', amount: 5000, currency: 'CLP', idempotency_key:
|
476
|
+
)
|
477
|
+
```
|
157
478
|
|
158
|
-
|
479
|
+
#### Account Verification with Idempotency Key
|
159
480
|
|
481
|
+
```ruby
|
482
|
+
idempotency_key = SecureRandom.uuid
|
483
|
+
account_verification = client.v2.account_verifications.create(
|
484
|
+
account_number: 'account_number', idempotency_key:
|
485
|
+
)
|
160
486
|
```
|
161
|
-
|
487
|
+
|
488
|
+
### About idempotency keys
|
489
|
+
|
490
|
+
- Idempotency keys can be up to 255 characters long
|
491
|
+
- Use consistent unique identifiers for the same logical operation (e.g. order IDs, transaction references). If you set them randomly, we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions.
|
492
|
+
- The same idempotency key will return the same result, including errors
|
493
|
+
- Keys are automatically removed after 24 hours
|
494
|
+
- Only POST and PATCH requests currently support idempotency keys
|
495
|
+
- If parameters differ with the same key, an error will be raised
|
496
|
+
|
497
|
+
For more information, see the [Fintoc API documentation on idempotent requests](https://docs.fintoc.com/reference/idempotent-requests).
|
498
|
+
|
499
|
+
## Development
|
500
|
+
|
501
|
+
### Dependencies
|
502
|
+
|
503
|
+
This gem supports **Ruby 2.3+** but development requires modern tooling:
|
504
|
+
|
505
|
+
- **Ruby:** 2.3+ (3.2+ recommended for development)
|
506
|
+
- **Bundler:** 2.7+ (for development)
|
507
|
+
- **Git:** For version control
|
508
|
+
|
509
|
+
### Setup
|
510
|
+
|
511
|
+
```bash
|
512
|
+
# Clone the repository
|
513
|
+
git clone https://github.com/fintoc-com/fintoc-ruby.git
|
514
|
+
cd fintoc-ruby
|
515
|
+
|
516
|
+
# Install dependencies (requires Bundler 2.7+)
|
517
|
+
bundle install
|
518
|
+
|
519
|
+
# Run tests
|
520
|
+
bundle exec rspec
|
521
|
+
|
522
|
+
# Run linting
|
523
|
+
bundle exec rubocop
|
162
524
|
```
|
163
525
|
|
164
526
|
## Contributing
|
165
527
|
|
166
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/fintoc-com/fintoc.
|
528
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/fintoc-com/fintoc-ruby](https://github.com/fintoc-com/fintoc-ruby).
|
data/Rakefile
CHANGED
data/fintoc.gemspec
CHANGED
@@ -9,12 +9,13 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.summary = 'The official Ruby client for the Fintoc API.'
|
10
10
|
spec.description = 'The official Ruby client for the Fintoc API.'
|
11
11
|
spec.homepage = 'https://github.com/fintoc-com/fintoc-ruby'
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new('>= 2.
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 3.2.2')
|
13
13
|
|
14
14
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
15
15
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
17
17
|
spec.metadata['source_code_uri'] = 'https://github.com/fintoc-com/fintoc-ruby'
|
18
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
18
19
|
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
19
20
|
|
20
21
|
# Specify which files should be added to the gem when it is released.
|
@@ -26,11 +27,6 @@ Gem::Specification.new do |spec|
|
|
26
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
28
|
spec.require_paths = ['lib']
|
28
29
|
spec.add_dependency 'http'
|
30
|
+
spec.add_dependency 'money-rails'
|
29
31
|
spec.add_dependency 'tabulate'
|
30
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
-
spec.add_development_dependency 'rubocop', '~> 0.81.0'
|
32
|
-
spec.add_development_dependency 'rubocop-performance'
|
33
|
-
spec.add_development_dependency 'rubocop-rspec'
|
34
|
-
spec.add_development_dependency 'vcr'
|
35
|
-
spec.add_development_dependency 'webmock'
|
36
32
|
end
|