From 349a35be4b0fe791dd90a42178233fa8ebb765c1 Mon Sep 17 00:00:00 2001 From: Pedro Bahamondes Date: Mon, 8 Sep 2025 18:41:49 -0300 Subject: [PATCH 1/3] feature(readme): Prefer using Fintoc::Client over Fintoc::V1/V2::Client in docs examples --- README.md | 124 +++++++++++++++++++++++++++--------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index d308eb3..d32e07c 100644 --- a/README.md +++ b/README.md @@ -63,8 +63,8 @@ Or install it yourself as: ```ruby require 'fintoc' -client_v1 = Fintoc::V1::Client.new('api_key') -link = client_v1.links.get('link_token') +client = Fintoc::Client.new('api_key', 'jws_private_key') +link = client.v1.links.get('link_token') account = link.find(type: 'checking_account') # Get the last 30 movements @@ -85,12 +85,12 @@ The Fintoc Ruby client is organized into separate clients that mirror the offici The API client currently provides access to part of the Movements API: ```ruby -client = Fintoc::V1::Client.new('api_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Link management -links = client_v1.links.list -link = client_v1.links.get('link_token') -client_v1.links.delete('link_id') +links = client.v1.links.list +link = client.v1.links.get('link_token') +client.v1.links.delete('link_id') # Account access account = link.find(id: account_id) @@ -101,46 +101,46 @@ account = link.find(id: account_id) The API V2 client currently provides access to part of the Transfers API: ```ruby -client = Fintoc::V1::Client.new('api_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Entities -entities = client_v2.entities.list -entity = client_v2.entities.get('entity_id') +entities = client.v2.entities.list +entity = client.v2.entities.get('entity_id') # Transfer Accounts -accounts = client_v2.accounts.list -account = client_v2.accounts.get('account_id') -account = client_v2.accounts.create(entity_id: 'entity_id', description: 'My Account') -client_v2.accounts.update('account_id', description: 'Updated') +accounts = client.v2.accounts.list +account = client.v2.accounts.get('account_id') +account = client.v2.accounts.create(entity_id: 'entity_id', description: 'My Account') +client.v2.accounts.update('account_id', description: 'Updated') # Account Numbers -account_numbers = client_v2.account_numbers.list -account_number = client_v2.account_numbers.get('account_number_id') -account_number = client_v2.account_numbers.create(account_id: 'account_id', description: 'Main') -client_v2.account_numbers.update('account_number_id', description: 'Updated') +account_numbers = client.v2.account_numbers.list +account_number = client.v2.account_numbers.get('account_number_id') +account_number = client.v2.account_numbers.create(account_id: 'account_id', description: 'Main') +client.v2.account_numbers.update('account_number_id', description: 'Updated') # Transfers -transfers = client_v2.transfers.list -transfer = client_v2.transfers.get('transfer_id') -transfer = client_v2.transfers.create( +transfers = client.v2.transfers.list +transfer = client.v2.transfers.get('transfer_id') +transfer = client.v2.transfers.create( amount: 1000, currency: 'CLP', account_id: 'account_id', counterparty: {...} ) -client_v2.transfers.return('transfer_id') +client.v2.transfers.return('transfer_id') # Simulate -simulated_transfer = client_v2.simulate.receive_transfer( +simulated_transfer = client.v2.simulate.receive_transfer( account_number_id: 'account_number_id', amount: 1000, currency: 'CLP' ) # Account Verifications -account_verifications = client_v2.account_verifications.list -account_verification = client_v2.account_verifications.get('account_verification_id') -account_verification = client_v2.account_verifications.create(account_number: 'account_number') +account_verifications = client.v2.account_verifications.list +account_verification = client.v2.account_verifications.get('account_verification_id') +account_verification = client.v2.account_verifications.create(account_number: 'account_number') # TODO: Movements ``` @@ -150,7 +150,7 @@ account_verification = client_v2.account_verifications.create(account_number: 'a The methods of the previous `Fintoc::Client` class implementation are kept for backward compatibility purposes. ```ruby -client = Fintoc::V1::Client.new('api_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') link = client.get_link('link_token') links = client.get_links @@ -171,13 +171,13 @@ This client does not support all Fintoc API endpoints yet. For complete informat ```ruby require 'fintoc' -client = Fintoc::V1::Client.new('api_key') -link = client_v1.links.get('link_token') +client = Fintoc::Client.new('api_key', 'jws_private_key') +link = client.v1.links.get('link_token') puts link.accounts # Or... you can pretty print all the accounts in a Link -link = client_v1.links.get('link_token') +link = client.v1.links.get('link_token') link.show_accounts ``` @@ -187,8 +187,8 @@ If you want to find a specific account in a link, you can use **find**. You can ```ruby require 'fintoc' -client = Fintoc::V1::Client.new('api_key') -link = client_v1.links.get('link_token') +client = Fintoc::Client.new('api_key', 'jws_private_key') +link = client.v1.links.get('link_token') account = link.find(type: 'checking_account') # Or by number @@ -203,8 +203,8 @@ You can also search for multiple accounts matching a specific criteria with **fi ```ruby require 'fintoc' -client = Fintoc::V1::Client.new('api_key') -link = client_v1.links.get('link_token') +client = Fintoc::Client.new('api_key', 'jws_private_key') +link = client.v1.links.get('link_token') accounts = link.find_all(currency: 'CLP') ``` @@ -213,8 +213,8 @@ To update the account balance you can use **update_balance**: ```ruby require 'fintoc' -client = Fintoc::V1::Client.new('api_key') -link = client_v1.links.get('link_token') +client = Fintoc::Client.new('api_key', 'jws_private_key') +link = client.v1.links.get('link_token') account = link.find(number: '1111111') account.update_balance ``` @@ -225,8 +225,8 @@ account.update_balance require 'fintoc' require 'time' -client = Fintoc::V1::Client.new('api_key') -link = client_v1.links.get('link_token') +client = Fintoc::Client.new('api_key', 'jws_private_key') +link = client.v1.links.get('link_token') account = link.find(type: 'checking_account') # You can get the account movements since a specific DateTime @@ -249,20 +249,20 @@ Calling **movements.list** without arguments gets the last 30 movements of the a ```ruby require 'fintoc' -client_v2 = Fintoc::V2::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Get all entities -entities = client_v2.entities.list +entities = client.v2.entities.list # Get a specific entity -entity = client_v2.entities.get('entity_id') +entity = client.v2.entities.get('entity_id') ``` You can also list entities with pagination: ```ruby # Get entities with pagination -entities = client_v2.entities.list(limit: 10, starting_after: 'entity_id') +entities = client.v2.entities.list(limit: 10, starting_after: 'entity_id') ``` #### Transfer Accounts @@ -270,22 +270,22 @@ entities = client_v2.entities.list(limit: 10, starting_after: 'entity_id') ```ruby require 'fintoc' -client_v2 = Fintoc::V2::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Create a transfer account -account = client_v2.accounts.create( +account = client.v2.accounts.create( entity_id: 'entity_id', description: 'My Business Account' ) # Get a specific account -account = client_v2.accounts.get('account_id') +account = client.v2.accounts.get('account_id') # List all accounts -accounts = client_v2.accounts.list +accounts = client.v2.accounts.list # Update an account -updated_account = client_v2.accounts.update('account_id', description: 'Updated Description') +updated_account = client.v2.accounts.update('account_id', description: 'Updated Description') ``` #### Account Numbers @@ -293,22 +293,22 @@ updated_account = client_v2.accounts.update('account_id', description: 'Updated ```ruby require 'fintoc' -client_v2 = Fintoc::V2::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Create an account number -account_number = client_v2.account_numbers.create( +account_number = client.v2.account_numbers.create( account_id: 'account_id', description: 'Main account number' ) # Get a specific account number -account_number = client_v2.account_numbers.get('account_number_id') +account_number = client.v2.account_numbers.get('account_number_id') # List all account numbers -account_numbers = client_v2.account_numbers.list +account_numbers = client.v2.account_numbers.list # Update an account number -updated_account_number = client_v2.account_numbers.update( +updated_account_number = client.v2.account_numbers.update( 'account_number_id', description: 'Updated account number' ) @@ -319,10 +319,10 @@ updated_account_number = client_v2.account_numbers.update( ```ruby require 'fintoc' -client_v2 = Fintoc::V2::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Create a transfer -transfer = client_v2.transfers.create( +transfer = client.v2.transfers.create( amount: 10000, currency: 'CLP', account_id: 'account_id', @@ -337,13 +337,13 @@ transfer = client_v2.transfers.create( ) # Get a specific transfer -transfer = client_v2.transfers.get('transfer_id') +transfer = client.v2.transfers.get('transfer_id') # List all transfers -transfers = client_v2.transfers.list +transfers = client.v2.transfers.list # Return a transfer -returned_transfer = client_v2.transfers.return('transfer_id') +returned_transfer = client.v2.transfers.return('transfer_id') ``` #### Simulate @@ -351,10 +351,10 @@ returned_transfer = client_v2.transfers.return('transfer_id') ```ruby require 'fintoc' -client_v2 = Fintoc::V2::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Simulate receiving a transfer -simulated_transfer = client_v2.simulate.receive_transfer( +simulated_transfer = client.v2.simulate.receive_transfer( account_number_id: 'account_number_id', amount: 5000, currency: 'CLP' @@ -366,16 +366,16 @@ simulated_transfer = client_v2.simulate.receive_transfer( ```ruby require 'fintoc' -client_v2 = Fintoc::V2::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', 'jws_private_key') # Create an account verification -account_verification = client_v2.account_verifications.create(account_number: 'account_number') +account_verification = client.v2.account_verifications.create(account_number: 'account_number') # Get a specific account verification -account_verification = client_v2.account_verifications.get('account_verification_id') +account_verification = client.v2.account_verifications.get('account_verification_id') # List all account verifications -account_verifications = client_v2.account_verifications.list +account_verifications = client.v2.account_verifications.list ``` ## Development From 6227bd94ae1eaa7abe30f95e6d282a808d2c91e7 Mon Sep 17 00:00:00 2001 From: Pedro Bahamondes Date: Mon, 8 Sep 2025 18:49:52 -0300 Subject: [PATCH 2/3] refactor(spec): Fix typo in specs --- spec/lib/fintoc/client_spec.rb | 2 +- spec/lib/fintoc/v1/account_spec.rb | 2 +- spec/lib/fintoc/v1/balance_spec.rb | 2 +- spec/lib/fintoc/v1/institution_spec.rb | 2 +- spec/lib/fintoc/v1/link_spec.rb | 2 +- spec/lib/fintoc/v1/movement_spec.rb | 4 ++-- spec/lib/fintoc/v1/transfer_account_spec.rb | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/lib/fintoc/client_spec.rb b/spec/lib/fintoc/client_spec.rb index 6111f2e..ad1d03b 100644 --- a/spec/lib/fintoc/client_spec.rb +++ b/spec/lib/fintoc/client_spec.rb @@ -9,7 +9,7 @@ let(:client) { described_class.new(api_key, jws_private_key: jws_private_key) } describe '.new' do - it 'create an instance Client' do + it 'creates an instance Client' do expect(client).to be_an_instance_of(described_class) end diff --git a/spec/lib/fintoc/v1/account_spec.rb b/spec/lib/fintoc/v1/account_spec.rb index b9eb14c..7c2ff27 100644 --- a/spec/lib/fintoc/v1/account_spec.rb +++ b/spec/lib/fintoc/v1/account_spec.rb @@ -30,7 +30,7 @@ let(:linked_account) { link.find(type: 'checking_account') } describe '#new' do - it 'create an instance of Account' do + it 'creates an instance of Account' do expect(account).to be_an_instance_of(described_class) end end diff --git a/spec/lib/fintoc/v1/balance_spec.rb b/spec/lib/fintoc/v1/balance_spec.rb index 069fecd..d2ea1b8 100644 --- a/spec/lib/fintoc/v1/balance_spec.rb +++ b/spec/lib/fintoc/v1/balance_spec.rb @@ -5,7 +5,7 @@ let(:balance) { described_class.new(**data) } describe '#new' do - it 'create an instance of Balance' do + it 'creates an instance of Balance' do expect(balance).to be_an_instance_of(described_class) end diff --git a/spec/lib/fintoc/v1/institution_spec.rb b/spec/lib/fintoc/v1/institution_spec.rb index d2be9d5..bdc7f84 100644 --- a/spec/lib/fintoc/v1/institution_spec.rb +++ b/spec/lib/fintoc/v1/institution_spec.rb @@ -8,7 +8,7 @@ let(:institution) { described_class.new(**data) } describe '#new' do - it 'create an instance of Institution' do + it 'creates an instance of Institution' do expect(institution).to be_an_instance_of(described_class) end end diff --git a/spec/lib/fintoc/v1/link_spec.rb b/spec/lib/fintoc/v1/link_spec.rb index d5e2461..a0f4502 100644 --- a/spec/lib/fintoc/v1/link_spec.rb +++ b/spec/lib/fintoc/v1/link_spec.rb @@ -55,7 +55,7 @@ let(:api_key) { 'sk_test_SeCrEt_aPi_KeY' } describe '#new' do - it 'create an instance of Link' do + it 'creates an instance of Link' do expect(link).to be_an_instance_of(described_class) end end diff --git a/spec/lib/fintoc/v1/movement_spec.rb b/spec/lib/fintoc/v1/movement_spec.rb index 1339227..87ba429 100644 --- a/spec/lib/fintoc/v1/movement_spec.rb +++ b/spec/lib/fintoc/v1/movement_spec.rb @@ -33,7 +33,7 @@ describe '.new' do context 'when movement is transfer' do - it 'create an instance of Movement' do # rubocop:disable RSpec/MultipleExpectations + it 'creates an instance of Movement' do # rubocop:disable RSpec/MultipleExpectations expect(movement).to be_an_instance_of(described_class) expect(movement.id).to eq('BO381oEATXonG6bj') expect(movement.amount).to eq(59400) @@ -68,7 +68,7 @@ data[:transaction_date] = nil end - it 'create an instance of Movement' do # rubocop:disable RSpec/MultipleExpectations + it 'creates an instance of Movement' do # rubocop:disable RSpec/MultipleExpectations expect(movement).to be_an_instance_of(described_class) expect(movement.id).to eq('BO381oEATXonG6bj') expect(movement.amount).to eq(59400) diff --git a/spec/lib/fintoc/v1/transfer_account_spec.rb b/spec/lib/fintoc/v1/transfer_account_spec.rb index 86951da..f4e1790 100644 --- a/spec/lib/fintoc/v1/transfer_account_spec.rb +++ b/spec/lib/fintoc/v1/transfer_account_spec.rb @@ -12,7 +12,7 @@ let(:transfer) { described_class.new(**data) } describe '#new' do - it 'create an instance of TransferAccount' do + it 'creates an instance of TransferAccount' do expect(transfer).to be_an_instance_of(described_class) end end From 086b90a7feea2afd4d5fcb9c92ebf318a29fee0c Mon Sep 17 00:00:00 2001 From: Pedro Bahamondes Date: Mon, 8 Sep 2025 19:00:20 -0300 Subject: [PATCH 3/3] refactor(readme): Pass jws private key as named parameter --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d32e07c..cbd96c0 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Or install it yourself as: ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.v1.links.get('link_token') account = link.find(type: 'checking_account') @@ -85,7 +85,7 @@ The Fintoc Ruby client is organized into separate clients that mirror the offici The API client currently provides access to part of the Movements API: ```ruby -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Link management links = client.v1.links.list @@ -101,7 +101,7 @@ account = link.find(id: account_id) The API V2 client currently provides access to part of the Transfers API: ```ruby -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Entities entities = client.v2.entities.list @@ -150,7 +150,7 @@ account_verification = client.v2.account_verifications.create(account_number: 'a The methods of the previous `Fintoc::Client` class implementation are kept for backward compatibility purposes. ```ruby -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.get_link('link_token') links = client.get_links @@ -171,7 +171,7 @@ This client does not support all Fintoc API endpoints yet. For complete informat ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.v1.links.get('link_token') puts link.accounts @@ -187,7 +187,7 @@ If you want to find a specific account in a link, you can use **find**. You can ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.v1.links.get('link_token') account = link.find(type: 'checking_account') @@ -203,7 +203,7 @@ You can also search for multiple accounts matching a specific criteria with **fi ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.v1.links.get('link_token') accounts = link.find_all(currency: 'CLP') ``` @@ -213,7 +213,7 @@ To update the account balance you can use **update_balance**: ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.v1.links.get('link_token') account = link.find(number: '1111111') account.update_balance @@ -225,7 +225,7 @@ account.update_balance require 'fintoc' require 'time' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') link = client.v1.links.get('link_token') account = link.find(type: 'checking_account') @@ -249,7 +249,7 @@ Calling **movements.list** without arguments gets the last 30 movements of the a ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Get all entities entities = client.v2.entities.list @@ -270,7 +270,7 @@ entities = client.v2.entities.list(limit: 10, starting_after: 'entity_id') ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Create a transfer account account = client.v2.accounts.create( @@ -293,7 +293,7 @@ updated_account = client.v2.accounts.update('account_id', description: 'Updated ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Create an account number account_number = client.v2.account_numbers.create( @@ -319,7 +319,7 @@ updated_account_number = client.v2.account_numbers.update( ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Create a transfer transfer = client.v2.transfers.create( @@ -351,7 +351,7 @@ returned_transfer = client.v2.transfers.return('transfer_id') ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Simulate receiving a transfer simulated_transfer = client.v2.simulate.receive_transfer( @@ -366,7 +366,7 @@ simulated_transfer = client.v2.simulate.receive_transfer( ```ruby require 'fintoc' -client = Fintoc::Client.new('api_key', 'jws_private_key') +client = Fintoc::Client.new('api_key', jws_private_key: 'jws_private_key') # Create an account verification account_verification = client.v2.account_verifications.create(account_number: 'account_number')