afterbanks-api-ruby 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +1 -1
- data/README.md +11 -5
- data/lib/afterbanks/base.rb +23 -27
- data/lib/afterbanks/resources/account.rb +4 -1
- data/lib/afterbanks/resources/bank.rb +62 -11
- data/lib/afterbanks/version.rb +1 -1
- metadata +3 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7e8930f102e85517209fcce5b5b135df8a2c2ef8f006b34373d2f3f8fb506c6c
|
4
|
+
data.tar.gz: c0dc2f9f696a0c7deb911c8c97540c58c24ae279889fcbf1e817523c9d004379
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0399b89536f56a7a7a005b1de08a39467e904f334d93e71785417e7484dc52c33a5ddcbbe45c071ccb2f33b6d6b95277bf948db36b21f05f0f4d917c22c08985'
|
7
|
+
data.tar.gz: 8470ba253a635d0fe30f37ae3734ce9d71bef65d95065e0ec53c45a8f6792f9bad155ba69437e73e32d1e1beb5d9f60638510a54d896f89e6e2fc9d8681307cb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,11 +4,6 @@
|
|
4
4
|
|
5
5
|
This is a Ruby client for the Afterbanks' API
|
6
6
|
|
7
|
-
Changelog
|
8
|
-
---------
|
9
|
-
|
10
|
-
* v.0.1.0 First vull version, including resource wrapping (for banks, accounts, transactions and the user) and separate exceptions for each different code.
|
11
|
-
|
12
7
|
Installation
|
13
8
|
---------
|
14
9
|
|
@@ -35,6 +30,17 @@ end
|
|
35
30
|
|
36
31
|
You can set a `logger` as well.
|
37
32
|
|
33
|
+
Changelog
|
34
|
+
---------
|
35
|
+
|
36
|
+
* v.0.3.0 Set a higher timeout so it works properly with ING Direct
|
37
|
+
* v.0.2.3 Better logging
|
38
|
+
* v.0.2.2 Better naming (fix Caixa Guissona, Caixa Burriana and Banco Pichincha)
|
39
|
+
* v.0.2.1 Better naming for banks (add Particulares for the proper ones, and use Caixa Enginyers)
|
40
|
+
* v.0.2.0 Allow adding an (opt-in) random parameter to Afterbanks::Account.list to avoid caching
|
41
|
+
* v.0.1.1 Fix rake security issue and remove specific Ruby version dependency.
|
42
|
+
* v.0.1.0 First vull version, including resource wrapping (for banks, accounts, transactions and the user) and separate exceptions for each different code.
|
43
|
+
|
38
44
|
TODO
|
39
45
|
----
|
40
46
|
|
data/lib/afterbanks/base.rb
CHANGED
@@ -16,7 +16,8 @@ module Afterbanks
|
|
16
16
|
def api_call(method:, path:, params: {})
|
17
17
|
url = 'https://api.afterbanks.com' + path
|
18
18
|
|
19
|
-
|
19
|
+
# Timeout is set to 5min: some banks take a lot to respond (e.g. ING Direct)
|
20
|
+
request_params = { method: method, url: url, timeout: 60*5 }
|
20
21
|
|
21
22
|
if method == :post
|
22
23
|
request_params.merge!(payload: params)
|
@@ -50,38 +51,33 @@ module Afterbanks
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def log_request(method:, url:, params: {}, debug_id: nil)
|
53
|
-
|
54
|
+
logger = Afterbanks.configuration.logger
|
55
|
+
return if logger.nil?
|
54
56
|
|
55
|
-
|
56
|
-
log_message(message: "=> #{method.upcase} #{url}")
|
57
|
+
now = Time.now
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
safe_params = {}
|
60
|
+
params.each do |key, value|
|
61
|
+
safe_value = if %w{servicekey user pass pass2}.include?(key.to_s)
|
62
|
+
"<masked>"
|
63
|
+
else
|
64
|
+
value
|
65
|
+
end
|
61
66
|
|
62
|
-
|
63
|
-
log_message(message: "* Params")
|
64
|
-
params.each do |key, value|
|
65
|
-
safe_value = if %w{servicekey user pass pass2}.include?(key.to_s)
|
66
|
-
"<masked>"
|
67
|
-
else
|
68
|
-
value
|
69
|
-
end
|
67
|
+
safe_value = safe_value.to_s if safe_value.is_a?(Symbol)
|
70
68
|
|
71
|
-
|
72
|
-
end
|
73
|
-
else
|
74
|
-
log_message(message: "* No params")
|
69
|
+
safe_params[key] = safe_value
|
75
70
|
end
|
76
|
-
end
|
77
71
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
72
|
+
logger.info(
|
73
|
+
message: 'Afterbanks request',
|
74
|
+
method: method.upcase.to_s,
|
75
|
+
url: url,
|
76
|
+
time: now.to_s,
|
77
|
+
timestamp: now.to_i,
|
78
|
+
debug_id: debug_id || 'none',
|
79
|
+
params: safe_params
|
80
|
+
)
|
85
81
|
end
|
86
82
|
|
87
83
|
private
|
@@ -11,7 +11,8 @@ module Afterbanks
|
|
11
11
|
holders: :hash
|
12
12
|
|
13
13
|
def self.list(service:, username:, password:, password2: nil,
|
14
|
-
document_type: nil, session_id: nil, otp: nil, counter_id: nil
|
14
|
+
document_type: nil, session_id: nil, otp: nil, counter_id: nil,
|
15
|
+
avoid_caching: false)
|
15
16
|
|
16
17
|
params = {
|
17
18
|
servicekey: Afterbanks.configuration.servicekey,
|
@@ -27,6 +28,8 @@ module Afterbanks
|
|
27
28
|
params.merge!(OTP: otp) unless otp.nil?
|
28
29
|
params.merge!(counterId: counter_id) unless counter_id.nil?
|
29
30
|
|
31
|
+
params.merge!(randomizer: Time.now.to_i) if avoid_caching
|
32
|
+
|
30
33
|
response, debug_id = Afterbanks.api_call(
|
31
34
|
method: :post,
|
32
35
|
path: '/V3/',
|
@@ -24,16 +24,11 @@ module Afterbanks
|
|
24
24
|
path: '/forms/'
|
25
25
|
)
|
26
26
|
|
27
|
-
if ordered
|
28
|
-
response.sort! do |bank1, bank2|
|
29
|
-
bank1['fullname'].downcase <=> bank2['fullname'].downcase
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
27
|
Response.new(
|
34
28
|
result: Collection.new(
|
35
29
|
banks_information_for(
|
36
|
-
response: response
|
30
|
+
response: response,
|
31
|
+
ordered: ordered
|
37
32
|
),
|
38
33
|
self
|
39
34
|
),
|
@@ -43,18 +38,74 @@ module Afterbanks
|
|
43
38
|
|
44
39
|
private
|
45
40
|
|
46
|
-
def self.banks_information_for(response:)
|
41
|
+
def self.banks_information_for(response:, ordered:)
|
47
42
|
banks_information = []
|
48
43
|
|
44
|
+
services_number_by_bank_id = {}
|
45
|
+
response.each { |bank_information|
|
46
|
+
bank_id = bank_id_for(bank_information: bank_information)
|
47
|
+
services_number_by_bank_id[bank_id] ||= 0
|
48
|
+
services_number_by_bank_id[bank_id] += 1
|
49
|
+
}
|
50
|
+
|
49
51
|
response.each do |bank_information|
|
50
|
-
|
51
|
-
bank_information
|
52
|
-
|
52
|
+
bank_information['fullname'] = bank_name_for(
|
53
|
+
bank_information: bank_information,
|
54
|
+
services_number_by_bank_id: services_number_by_bank_id
|
55
|
+
)
|
53
56
|
|
54
57
|
banks_information << bank_information
|
55
58
|
end
|
56
59
|
|
60
|
+
if ordered
|
61
|
+
banks_information.sort! do |bank_information1, bank_information2|
|
62
|
+
bank_information1['fullname'].downcase <=> bank_information2['fullname'].downcase
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
57
66
|
banks_information
|
58
67
|
end
|
68
|
+
|
69
|
+
def self.bank_name_for(bank_information:, services_number_by_bank_id:)
|
70
|
+
# Name changes:
|
71
|
+
# 1. Add Particulares if there are different personal/company endpoints
|
72
|
+
# 2. Add Empresas following the same reason
|
73
|
+
# 3. Rename Caja Ingenieros into Caixa d'Enginyers (most known name)
|
74
|
+
# 4. Rename Caixa Guisona into Caixa Guissona (fix typo)
|
75
|
+
# 5. Rename Caixa burriana into Caixa Burriana (fix typo)
|
76
|
+
# 6. Rename Bancho Pichincha into Banco Pichincha (fix typo)
|
77
|
+
|
78
|
+
if bank_information['service'] == 'cajaingenieros'
|
79
|
+
return "Caixa d'Enginyers"
|
80
|
+
end
|
81
|
+
|
82
|
+
if bank_information['service'] == 'caixaguissona'
|
83
|
+
return "Caixa Guissona"
|
84
|
+
end
|
85
|
+
|
86
|
+
if bank_information['service'] == 'caixaruralburriana'
|
87
|
+
return "Caixa Burriana"
|
88
|
+
end
|
89
|
+
|
90
|
+
if bank_information['service'] == 'pichincha'
|
91
|
+
return "Banco Pichincha"
|
92
|
+
end
|
93
|
+
|
94
|
+
fullname = bank_information['fullname']
|
95
|
+
if bank_information['business'] == "1"
|
96
|
+
return "#{fullname} Empresas"
|
97
|
+
end
|
98
|
+
|
99
|
+
bank_id = bank_id_for(bank_information: bank_information)
|
100
|
+
if services_number_by_bank_id[bank_id] > 1
|
101
|
+
return "#{fullname} Particulares"
|
102
|
+
end
|
103
|
+
|
104
|
+
fullname
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.bank_id_for(bank_information:)
|
108
|
+
bank_information['service'].split("_").first
|
109
|
+
end
|
59
110
|
end
|
60
111
|
end
|
data/lib/afterbanks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: afterbanks-api-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Bellonch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- ".circleci/config.yml"
|
105
105
|
- ".gitignore"
|
106
106
|
- ".rspec"
|
107
|
-
- ".ruby-version"
|
108
107
|
- Gemfile
|
109
108
|
- Gemfile.lock
|
110
109
|
- README.md
|
@@ -141,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
140
|
version: '0'
|
142
141
|
requirements: []
|
143
142
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.6.
|
143
|
+
rubygems_version: 2.7.6.2
|
145
144
|
signing_key:
|
146
145
|
specification_version: 4
|
147
146
|
summary: Ruby client for the Afterbanks' API
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.4.1
|