fintoc 0.1.0 → 1.0.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 +47 -0
- data/.github/workflows/ci.yml +46 -0
- data/.rubocop.yml +14 -7
- data/CHANGELOG.md +40 -0
- data/Gemfile +20 -1
- data/Gemfile.lock +237 -61
- data/README.md +286 -42
- data/Rakefile +3 -3
- data/fintoc.gemspec +3 -7
- data/lib/config/initializers/money.rb +5 -0
- data/lib/fintoc/base_client.rb +150 -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 +59 -0
- data/lib/fintoc/v2/managers/account_verifications_manager.rb +45 -0
- data/lib/fintoc/v2/managers/accounts_manager.rb +54 -0
- data/lib/fintoc/v2/managers/entities_manager.rb +36 -0
- data/lib/fintoc/v2/managers/simulate_manager.rb +30 -0
- data/lib/fintoc/v2/managers/transfers_manager.rb +56 -0
- data/lib/fintoc/v2/resources/account.rb +105 -0
- data/lib/fintoc/v2/resources/account_number.rb +105 -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
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'tabulate'
|
3
|
-
require 'fintoc/utils'
|
4
|
-
require 'fintoc/resources/account'
|
5
|
-
require 'fintoc/resources/institution'
|
6
|
-
require 'tabulate'
|
7
|
-
|
8
|
-
module Fintoc
|
9
|
-
class Link
|
10
|
-
attr_reader :id, :username, :holder_type, :institution, :created_at, :mode,
|
11
|
-
:accounts, :link_token
|
12
|
-
include Utils
|
13
|
-
def initialize(
|
14
|
-
id:,
|
15
|
-
username:,
|
16
|
-
holder_type:,
|
17
|
-
institution:,
|
18
|
-
created_at:,
|
19
|
-
mode:,
|
20
|
-
accounts: nil,
|
21
|
-
link_token: nil,
|
22
|
-
client: nil,
|
23
|
-
**
|
24
|
-
)
|
25
|
-
@id = id
|
26
|
-
@username = username
|
27
|
-
@holder_type = holder_type
|
28
|
-
@institution = Fintoc::Institution.new(**institution)
|
29
|
-
@created_at = Date.iso8601(created_at)
|
30
|
-
@mode = mode
|
31
|
-
@accounts = if accounts.nil?
|
32
|
-
[]
|
33
|
-
else
|
34
|
-
accounts.map { |data| Fintoc::Account.new(**data, client: client) }
|
35
|
-
end
|
36
|
-
@token = link_token
|
37
|
-
@client = client
|
38
|
-
end
|
39
|
-
|
40
|
-
def find_all(**kwargs)
|
41
|
-
raise 'You must provide *exactly one* account field.' if kwargs.size != 1
|
42
|
-
|
43
|
-
field, value = kwargs.to_a.first
|
44
|
-
@accounts.select do |account|
|
45
|
-
account.send(field.to_sym) == value
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def find(**kwargs)
|
50
|
-
results = find_all(**kwargs)
|
51
|
-
results.any? ? results.first : nil
|
52
|
-
end
|
53
|
-
|
54
|
-
def show_accounts(rows = 5)
|
55
|
-
puts "This links has #{Utils.plurlize(@accounts.size, 'account')}"
|
56
|
-
|
57
|
-
return unless @accounts.any?
|
58
|
-
|
59
|
-
accounts = @accounts.to_a.slice(0, rows)
|
60
|
-
.map.with_index do |acc, index|
|
61
|
-
[index + 1, acc.name, acc.holder_name, account.currency]
|
62
|
-
end
|
63
|
-
headers = ['#', 'Name', 'Holder', 'Currency']
|
64
|
-
puts
|
65
|
-
puts tabulate(headers, accounts, indent: 4, style: 'fancy')
|
66
|
-
end
|
67
|
-
|
68
|
-
def update_accounts
|
69
|
-
@accounts.each do |account|
|
70
|
-
account.update_balance
|
71
|
-
account.update_movements
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def delete
|
76
|
-
@client.delete_link(@id)
|
77
|
-
end
|
78
|
-
|
79
|
-
def to_s
|
80
|
-
"<#{@username}@#{@institution.name}> 🔗 <Fintoc>"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
require 'date'
|
2
|
-
require 'fintoc/resources/transfer_account'
|
3
|
-
|
4
|
-
module Fintoc
|
5
|
-
class Movement
|
6
|
-
attr_reader :id, :amount, :currency, :description, :reference_id,
|
7
|
-
:post_date, :transaction_date, :type, :recipient_account,
|
8
|
-
:sender_account, :account, :comment
|
9
|
-
|
10
|
-
def initialize(
|
11
|
-
id:,
|
12
|
-
amount:,
|
13
|
-
currency:,
|
14
|
-
description:,
|
15
|
-
post_date:,
|
16
|
-
transaction_date:,
|
17
|
-
type:,
|
18
|
-
reference_id:,
|
19
|
-
recipient_account:,
|
20
|
-
sender_account:,
|
21
|
-
comment:,
|
22
|
-
**
|
23
|
-
)
|
24
|
-
@id = id
|
25
|
-
@amount = amount
|
26
|
-
@currency = currency
|
27
|
-
@description = description
|
28
|
-
@post_date = DateTime.iso8601(post_date)
|
29
|
-
@transaction_date = DateTime.iso8601(transaction_date) if transaction_date
|
30
|
-
@type = type
|
31
|
-
@reference_id = reference_id
|
32
|
-
@recipient_account = Fintoc::TransferAccount.new(**recipient_account) if recipient_account
|
33
|
-
@sender_account = Fintoc::TransferAccount.new(**sender_account) if sender_account
|
34
|
-
@comment = comment
|
35
|
-
end
|
36
|
-
|
37
|
-
def ==(other)
|
38
|
-
@id = other.id
|
39
|
-
end
|
40
|
-
|
41
|
-
alias eql? ==
|
42
|
-
|
43
|
-
def hash
|
44
|
-
@id.hash
|
45
|
-
end
|
46
|
-
|
47
|
-
def locale_date
|
48
|
-
@post_date.strftime('%x')
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_s
|
52
|
-
"#{@amount} (#{@description} @ #{locale_date})"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'fintoc/resources/institution'
|
2
|
-
|
3
|
-
module Fintoc
|
4
|
-
class TransferAccount
|
5
|
-
attr_reader :holder_id, :holder_name, :number, :institution
|
6
|
-
|
7
|
-
def initialize(holder_id:, holder_name:, number:, institution:, **)
|
8
|
-
@holder_id = holder_id
|
9
|
-
@holder_name = holder_name
|
10
|
-
@number = number
|
11
|
-
@institution = institution && Fintoc::Institution.new(**institution)
|
12
|
-
end
|
13
|
-
|
14
|
-
def id
|
15
|
-
object_id
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_s
|
19
|
-
@holder_id.to_s
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|