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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
module Fintoc
|
|
2
|
+
module V2
|
|
3
|
+
class AccountVerification
|
|
4
|
+
attr_reader :id, :object, :status, :reason, :transfer_id, :counterparty, :mode, :receipt_url,
|
|
5
|
+
:transaction_date
|
|
6
|
+
|
|
7
|
+
def initialize(
|
|
8
|
+
id:,
|
|
9
|
+
object:,
|
|
10
|
+
status:,
|
|
11
|
+
reason:,
|
|
12
|
+
transfer_id:,
|
|
13
|
+
counterparty:,
|
|
14
|
+
mode:,
|
|
15
|
+
receipt_url:,
|
|
16
|
+
transaction_date:,
|
|
17
|
+
client: nil,
|
|
18
|
+
**
|
|
19
|
+
)
|
|
20
|
+
@id = id
|
|
21
|
+
@object = object
|
|
22
|
+
@status = status
|
|
23
|
+
@reason = reason
|
|
24
|
+
@transfer_id = transfer_id
|
|
25
|
+
@counterparty = counterparty
|
|
26
|
+
@mode = mode
|
|
27
|
+
@receipt_url = receipt_url
|
|
28
|
+
@transaction_date = transaction_date
|
|
29
|
+
@client = client
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def to_s
|
|
33
|
+
"🔍 Account Verification (#{@id}) - #{@status}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def refresh
|
|
37
|
+
fresh_verification = @client.account_verifications.get(@id)
|
|
38
|
+
refresh_from_verification(fresh_verification)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def pending?
|
|
42
|
+
@status == 'pending'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def succeeded?
|
|
46
|
+
@status == 'succeeded'
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def failed?
|
|
50
|
+
@status == 'failed'
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def refresh_from_verification(verification)
|
|
56
|
+
unless verification.id == @id
|
|
57
|
+
raise ArgumentError, 'Account verification must be the same instance'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
@object = verification.object
|
|
61
|
+
@status = verification.status
|
|
62
|
+
@reason = verification.reason
|
|
63
|
+
@transfer_id = verification.transfer_id
|
|
64
|
+
@counterparty = verification.counterparty
|
|
65
|
+
@mode = verification.mode
|
|
66
|
+
@receipt_url = verification.receipt_url
|
|
67
|
+
@transaction_date = verification.transaction_date
|
|
68
|
+
|
|
69
|
+
self
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Fintoc
|
|
2
|
+
module V2
|
|
3
|
+
class Entity
|
|
4
|
+
attr_reader :object, :mode, :id, :holder_name, :holder_id, :is_root
|
|
5
|
+
|
|
6
|
+
def initialize(
|
|
7
|
+
object:,
|
|
8
|
+
mode:,
|
|
9
|
+
id:,
|
|
10
|
+
holder_name:,
|
|
11
|
+
holder_id:,
|
|
12
|
+
is_root:,
|
|
13
|
+
client: nil,
|
|
14
|
+
**
|
|
15
|
+
)
|
|
16
|
+
@object = object
|
|
17
|
+
@mode = mode
|
|
18
|
+
@id = id
|
|
19
|
+
@holder_name = holder_name
|
|
20
|
+
@holder_id = holder_id
|
|
21
|
+
@is_root = is_root
|
|
22
|
+
@client = client
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def to_s
|
|
26
|
+
"🏢 #{@holder_name} (#{@id})"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def refresh
|
|
30
|
+
fresh_entity = @client.entities.get(@id)
|
|
31
|
+
refresh_from_entity(fresh_entity)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def refresh_from_entity(entity)
|
|
37
|
+
unless entity.id == @id
|
|
38
|
+
raise ArgumentError, 'Entity must be the same instance'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
@object = entity.object
|
|
42
|
+
@mode = entity.mode
|
|
43
|
+
@holder_name = entity.holder_name
|
|
44
|
+
@holder_id = entity.holder_id
|
|
45
|
+
@is_root = entity.is_root
|
|
46
|
+
|
|
47
|
+
self
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
require 'money'
|
|
2
|
+
|
|
3
|
+
module Fintoc
|
|
4
|
+
module V2
|
|
5
|
+
class Transfer
|
|
6
|
+
attr_reader :id, :object, :amount, :currency, :direction, :status, :mode,
|
|
7
|
+
:post_date, :transaction_date, :comment, :reference_id, :receipt_url,
|
|
8
|
+
:tracking_key, :return_reason, :counterparty, :account_number,
|
|
9
|
+
:metadata, :created_at
|
|
10
|
+
|
|
11
|
+
def initialize( # rubocop:disable Metrics/MethodLength
|
|
12
|
+
id:,
|
|
13
|
+
object:,
|
|
14
|
+
amount:,
|
|
15
|
+
currency:,
|
|
16
|
+
status:,
|
|
17
|
+
mode:,
|
|
18
|
+
counterparty:,
|
|
19
|
+
direction: nil,
|
|
20
|
+
post_date: nil,
|
|
21
|
+
transaction_date: nil,
|
|
22
|
+
comment: nil,
|
|
23
|
+
reference_id: nil,
|
|
24
|
+
receipt_url: nil,
|
|
25
|
+
tracking_key: nil,
|
|
26
|
+
return_reason: nil,
|
|
27
|
+
account_number: nil,
|
|
28
|
+
metadata: {},
|
|
29
|
+
created_at: nil,
|
|
30
|
+
client: nil,
|
|
31
|
+
**
|
|
32
|
+
)
|
|
33
|
+
@id = id
|
|
34
|
+
@object = object
|
|
35
|
+
@amount = amount
|
|
36
|
+
@currency = currency
|
|
37
|
+
@direction = direction
|
|
38
|
+
@status = status
|
|
39
|
+
@mode = mode
|
|
40
|
+
@post_date = post_date
|
|
41
|
+
@transaction_date = transaction_date
|
|
42
|
+
@comment = comment
|
|
43
|
+
@reference_id = reference_id
|
|
44
|
+
@receipt_url = receipt_url
|
|
45
|
+
@tracking_key = tracking_key
|
|
46
|
+
@return_reason = return_reason
|
|
47
|
+
@counterparty = counterparty
|
|
48
|
+
@account_number = account_number
|
|
49
|
+
@metadata = metadata || {}
|
|
50
|
+
@created_at = created_at
|
|
51
|
+
@client = client
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def to_s
|
|
55
|
+
amount_str = Money.from_cents(@amount, @currency).format
|
|
56
|
+
direction_icon = inbound? ? '⬇️' : '⬆️'
|
|
57
|
+
"#{direction_icon} #{amount_str} (#{@id}) - #{@status}"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def refresh
|
|
61
|
+
fresh_transfer = @client.transfers.get(@id)
|
|
62
|
+
refresh_from_transfer(fresh_transfer)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def return_transfer
|
|
66
|
+
returned_transfer = @client.transfers.return(@id)
|
|
67
|
+
refresh_from_transfer(returned_transfer)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def pending?
|
|
71
|
+
@status == 'pending'
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def succeeded?
|
|
75
|
+
@status == 'succeeded'
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def failed?
|
|
79
|
+
@status == 'failed'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def returned?
|
|
83
|
+
@status == 'returned'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def return_pending?
|
|
87
|
+
@status == 'return_pending'
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def rejected?
|
|
91
|
+
@status == 'rejected'
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def inbound?
|
|
95
|
+
@direction == 'inbound'
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def outbound?
|
|
99
|
+
@direction == 'outbound'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
def refresh_from_transfer(transfer) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
105
|
+
unless transfer.id == @id
|
|
106
|
+
raise ArgumentError, 'Transfer must be the same instance'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
@object = transfer.object
|
|
110
|
+
@amount = transfer.amount
|
|
111
|
+
@currency = transfer.currency
|
|
112
|
+
@direction = transfer.direction
|
|
113
|
+
@status = transfer.status
|
|
114
|
+
@mode = transfer.mode
|
|
115
|
+
@post_date = transfer.post_date
|
|
116
|
+
@transaction_date = transfer.transaction_date
|
|
117
|
+
@comment = transfer.comment
|
|
118
|
+
@reference_id = transfer.reference_id
|
|
119
|
+
@receipt_url = transfer.receipt_url
|
|
120
|
+
@tracking_key = transfer.tracking_key
|
|
121
|
+
@return_reason = transfer.return_reason
|
|
122
|
+
@counterparty = transfer.counterparty
|
|
123
|
+
@account_number = transfer.account_number
|
|
124
|
+
@metadata = transfer.metadata
|
|
125
|
+
@created_at = transfer.created_at
|
|
126
|
+
|
|
127
|
+
self
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
data/lib/fintoc/version.rb
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'openssl'
|
|
4
|
+
require 'time'
|
|
5
|
+
require 'fintoc/errors'
|
|
6
|
+
|
|
7
|
+
module Fintoc
|
|
8
|
+
class WebhookSignature
|
|
9
|
+
EXPECTED_SCHEME = 'v1'
|
|
10
|
+
DEFAULT_TOLERANCE = 300 # 5 minutes
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
def verify_header(payload, header, secret, tolerance = DEFAULT_TOLERANCE) # rubocop:disable Naming/PredicateMethod
|
|
14
|
+
timestamp, signatures = parse_header(header)
|
|
15
|
+
|
|
16
|
+
verify_timestamp(timestamp, tolerance) if tolerance
|
|
17
|
+
|
|
18
|
+
expected_signature = compute_signature(payload, timestamp, secret)
|
|
19
|
+
signature = signatures[EXPECTED_SCHEME]
|
|
20
|
+
|
|
21
|
+
if signature.nil? || signature.empty? # rubocop:disable Rails/Blank
|
|
22
|
+
raise Fintoc::Errors::WebhookSignatureError.new("No #{EXPECTED_SCHEME} signature found")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
unless same_signatures?(signature, expected_signature)
|
|
26
|
+
raise Fintoc::Errors::WebhookSignatureError.new('Signature mismatch')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def compute_signature(payload, timestamp, secret)
|
|
33
|
+
signed_payload = "#{timestamp}.#{payload}"
|
|
34
|
+
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), secret, signed_payload)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def parse_header(header)
|
|
40
|
+
elements = header.split(',').map(&:strip)
|
|
41
|
+
pairs = elements.map { |element| element.split('=', 2).map(&:strip) }
|
|
42
|
+
pairs = pairs.to_h
|
|
43
|
+
|
|
44
|
+
if pairs['t'].nil? || pairs['t'].empty? # rubocop:disable Rails/Blank
|
|
45
|
+
raise Fintoc::Errors::WebhookSignatureError.new('Missing timestamp in header')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
timestamp = pairs['t'].to_i
|
|
49
|
+
signatures = pairs.except('t')
|
|
50
|
+
|
|
51
|
+
[timestamp, signatures]
|
|
52
|
+
rescue StandardError => e
|
|
53
|
+
raise Fintoc::Errors::WebhookSignatureError.new(
|
|
54
|
+
'Unable to extract timestamp and signatures from header'
|
|
55
|
+
), cause: e
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def verify_timestamp(timestamp, tolerance)
|
|
59
|
+
now = Time.now.to_i
|
|
60
|
+
|
|
61
|
+
if timestamp < (now - tolerance)
|
|
62
|
+
raise Fintoc::Errors::WebhookSignatureError.new(
|
|
63
|
+
"Timestamp outside the tolerance zone (#{timestamp})"
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def same_signatures?(signature, expected_signature)
|
|
69
|
+
OpenSSL.secure_compare(expected_signature, signature)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
data/lib/fintoc.rb
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
if ENV['COVERAGE'] == 'true'
|
|
2
|
+
require 'simplecov'
|
|
3
|
+
require 'simplecov_text_formatter'
|
|
4
|
+
require 'simplecov_linter_formatter'
|
|
5
|
+
|
|
6
|
+
SimpleCov.start do
|
|
7
|
+
formatter SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter])
|
|
8
|
+
|
|
9
|
+
add_filter '/vendor/'
|
|
10
|
+
add_filter '/lib/fintoc.rb'
|
|
11
|
+
add_filter '/lib/fintoc/version.rb'
|
|
12
|
+
add_filter '/lib/tasks/simplecov_config.rb'
|
|
13
|
+
|
|
14
|
+
track_files 'lib/**/*.rb'
|
|
15
|
+
|
|
16
|
+
minimum_coverage 100
|
|
17
|
+
minimum_coverage_by_file 100
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fintoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Juan Ca Sardin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-09-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: http
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: money-rails
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -39,83 +39,13 @@ dependencies:
|
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '3.0'
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '3.0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rubocop
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - "~>"
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.81.0
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.81.0
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rubocop-performance
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - ">="
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rubocop-rspec
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - ">="
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: '0'
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - ">="
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: '0'
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: vcr
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - ">="
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: '0'
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - ">="
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: '0'
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: webmock
|
|
42
|
+
name: tabulate
|
|
113
43
|
requirement: !ruby/object:Gem::Requirement
|
|
114
44
|
requirements:
|
|
115
45
|
- - ">="
|
|
116
46
|
- !ruby/object:Gem::Version
|
|
117
47
|
version: '0'
|
|
118
|
-
type: :
|
|
48
|
+
type: :runtime
|
|
119
49
|
prerelease: false
|
|
120
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
51
|
requirements:
|
|
@@ -129,6 +59,8 @@ executables: []
|
|
|
129
59
|
extensions: []
|
|
130
60
|
extra_rdoc_files: []
|
|
131
61
|
files:
|
|
62
|
+
- ".github/pull_request_template.md"
|
|
63
|
+
- ".github/workflows/ci.yml"
|
|
132
64
|
- ".gitignore"
|
|
133
65
|
- ".rspec"
|
|
134
66
|
- ".rubocop.yml"
|
|
@@ -142,23 +74,43 @@ files:
|
|
|
142
74
|
- bin/console
|
|
143
75
|
- bin/setup
|
|
144
76
|
- fintoc.gemspec
|
|
77
|
+
- lib/config/initializers/money.rb
|
|
145
78
|
- lib/fintoc.rb
|
|
79
|
+
- lib/fintoc/base_client.rb
|
|
146
80
|
- lib/fintoc/client.rb
|
|
147
81
|
- lib/fintoc/constants.rb
|
|
148
82
|
- lib/fintoc/errors.rb
|
|
149
|
-
- lib/fintoc/
|
|
150
|
-
- lib/fintoc/resources/balance.rb
|
|
151
|
-
- lib/fintoc/resources/institution.rb
|
|
152
|
-
- lib/fintoc/resources/link.rb
|
|
153
|
-
- lib/fintoc/resources/movement.rb
|
|
154
|
-
- lib/fintoc/resources/transfer_account.rb
|
|
83
|
+
- lib/fintoc/jws.rb
|
|
155
84
|
- lib/fintoc/utils.rb
|
|
85
|
+
- lib/fintoc/v1/client/client.rb
|
|
86
|
+
- lib/fintoc/v1/managers/links_manager.rb
|
|
87
|
+
- lib/fintoc/v1/resources/account.rb
|
|
88
|
+
- lib/fintoc/v1/resources/balance.rb
|
|
89
|
+
- lib/fintoc/v1/resources/institution.rb
|
|
90
|
+
- lib/fintoc/v1/resources/link.rb
|
|
91
|
+
- lib/fintoc/v1/resources/movement.rb
|
|
92
|
+
- lib/fintoc/v1/resources/transfer_account.rb
|
|
93
|
+
- lib/fintoc/v2/client/client.rb
|
|
94
|
+
- lib/fintoc/v2/managers/account_numbers_manager.rb
|
|
95
|
+
- lib/fintoc/v2/managers/account_verifications_manager.rb
|
|
96
|
+
- lib/fintoc/v2/managers/accounts_manager.rb
|
|
97
|
+
- lib/fintoc/v2/managers/entities_manager.rb
|
|
98
|
+
- lib/fintoc/v2/managers/simulate_manager.rb
|
|
99
|
+
- lib/fintoc/v2/managers/transfers_manager.rb
|
|
100
|
+
- lib/fintoc/v2/resources/account.rb
|
|
101
|
+
- lib/fintoc/v2/resources/account_number.rb
|
|
102
|
+
- lib/fintoc/v2/resources/account_verification.rb
|
|
103
|
+
- lib/fintoc/v2/resources/entity.rb
|
|
104
|
+
- lib/fintoc/v2/resources/transfer.rb
|
|
156
105
|
- lib/fintoc/version.rb
|
|
106
|
+
- lib/fintoc/webhook_signature.rb
|
|
107
|
+
- lib/tasks/simplecov_config.rb
|
|
157
108
|
homepage: https://github.com/fintoc-com/fintoc-ruby
|
|
158
109
|
licenses: []
|
|
159
110
|
metadata:
|
|
160
111
|
homepage_uri: https://github.com/fintoc-com/fintoc-ruby
|
|
161
112
|
source_code_uri: https://github.com/fintoc-com/fintoc-ruby
|
|
113
|
+
rubygems_mfa_required: 'true'
|
|
162
114
|
post_install_message:
|
|
163
115
|
rdoc_options: []
|
|
164
116
|
require_paths:
|
|
@@ -167,14 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
167
119
|
requirements:
|
|
168
120
|
- - ">="
|
|
169
121
|
- !ruby/object:Gem::Version
|
|
170
|
-
version: 2.
|
|
122
|
+
version: 3.2.2
|
|
171
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
124
|
requirements:
|
|
173
125
|
- - ">="
|
|
174
126
|
- !ruby/object:Gem::Version
|
|
175
127
|
version: '0'
|
|
176
128
|
requirements: []
|
|
177
|
-
rubygems_version: 3.0.3
|
|
129
|
+
rubygems_version: 3.0.3.1
|
|
178
130
|
signing_key:
|
|
179
131
|
specification_version: 4
|
|
180
132
|
summary: The official Ruby client for the Fintoc API.
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
require 'tabulate'
|
|
2
|
-
require 'fintoc/utils'
|
|
3
|
-
require 'fintoc/resources/movement'
|
|
4
|
-
require 'fintoc/resources/balance'
|
|
5
|
-
|
|
6
|
-
module Fintoc
|
|
7
|
-
class Account
|
|
8
|
-
include Utils
|
|
9
|
-
attr_reader :id, :name, :holder_name, :currency, :type, :refreshed_at,
|
|
10
|
-
:official_name, :number, :holder_id, :balance, :movements
|
|
11
|
-
def initialize(
|
|
12
|
-
id:,
|
|
13
|
-
name:,
|
|
14
|
-
official_name:,
|
|
15
|
-
number:,
|
|
16
|
-
holder_id:,
|
|
17
|
-
holder_name:,
|
|
18
|
-
type:,
|
|
19
|
-
currency:,
|
|
20
|
-
refreshed_at: nil,
|
|
21
|
-
balance: nil,
|
|
22
|
-
movements: nil,
|
|
23
|
-
client: nil,
|
|
24
|
-
**
|
|
25
|
-
)
|
|
26
|
-
@id = id
|
|
27
|
-
@name = name
|
|
28
|
-
@official_name = official_name
|
|
29
|
-
@number = number
|
|
30
|
-
@holder_id = holder_id
|
|
31
|
-
@holder_name = holder_name
|
|
32
|
-
@type = type
|
|
33
|
-
@currency = currency
|
|
34
|
-
@refreshed_at = DateTime.iso8601(refreshed_at) if refreshed_at
|
|
35
|
-
@balance = Fintoc::Balance.new(**balance)
|
|
36
|
-
@movements = movements || []
|
|
37
|
-
@client = client
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def update_balance
|
|
41
|
-
@balance = Fintoc::Balance.new(**get_account[:balance])
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def get_movements(**params)
|
|
45
|
-
_get_movements(**params).lazy.map { |movement| Fintoc::Movement.new(**movement) }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def update_movements(**params)
|
|
49
|
-
@movements += get_movements(**params).to_a
|
|
50
|
-
@movements = @movements.uniq.sort_by(&:post_date)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def show_movements(rows = 5)
|
|
54
|
-
puts("This account has #{Utils.pluralize(@movements.size, 'movement')}.")
|
|
55
|
-
|
|
56
|
-
return unless @movements.any?
|
|
57
|
-
|
|
58
|
-
movements = @movements.to_a.slice(0, rows)
|
|
59
|
-
.map.with_index do |mov, index|
|
|
60
|
-
[index + 1, mov.amount, mov.currency, mov.description, mov.locale_date]
|
|
61
|
-
end
|
|
62
|
-
headers = ['#', 'Amount', 'Currency', 'Description', 'Date']
|
|
63
|
-
puts
|
|
64
|
-
puts tabulate(headers, movements, indent: 4, style: 'fancy')
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def to_s
|
|
68
|
-
"💰 #{@holder_name}’s #{@name} #{@balance}"
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
private
|
|
72
|
-
|
|
73
|
-
def get_account
|
|
74
|
-
@client.get.call("accounts/#{@id}")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def _get_movements(**params)
|
|
78
|
-
first = @client.get.call("accounts/#{@id}/movements", **params)
|
|
79
|
-
return first if params.empty?
|
|
80
|
-
|
|
81
|
-
first + Utils.flatten(@client.fetch_next)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Fintoc
|
|
4
|
-
class Balance
|
|
5
|
-
attr_reader :available, :current, :limit
|
|
6
|
-
def initialize(available:, current:, limit:)
|
|
7
|
-
@available = available
|
|
8
|
-
@current = current
|
|
9
|
-
@limit = limit
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def id
|
|
13
|
-
object_id
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def to_s
|
|
17
|
-
"#{@available} (#{@current})"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def inspect
|
|
21
|
-
"<Balance #{@available} (#{@current})>"
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module Fintoc
|
|
2
|
-
class Institution
|
|
3
|
-
attr_reader :id, :name, :country
|
|
4
|
-
def initialize(id:, name:, country:, **)
|
|
5
|
-
@id = id
|
|
6
|
-
@name = name
|
|
7
|
-
@country = country
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def to_s
|
|
11
|
-
"🏦 #{@name}"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def inspect
|
|
15
|
-
"<Institution #{@name}>"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|