bank_api 0.7.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/bank_api.rb +4 -4
- data/lib/bank_api/clients/banco_de_chile_company_client.rb +3 -3
- data/lib/bank_api/clients/banco_security/company_client.rb +3 -3
- data/lib/bank_api/clients/banco_security/concerns/balance.rb +31 -4
- data/lib/bank_api/clients/base_client.rb +3 -3
- data/lib/bank_api/exceptions.rb +1 -0
- data/lib/bank_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaf7fef43650e6c6ca07c066219e92cedaf2602d38b880386abfe0576c60cb94
|
4
|
+
data.tar.gz: 117c566f6481736b51acbb71457e7c78261ba607a87f670cf29ce777f018514c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59869a54dbcf09da1d4f163686b0617564c107b43f4049e46bc1bad357eb3e953045fc670696f6077cffd36a4db15a1714ec5847d214e8b0ccbfa24e9cbcdb6c
|
7
|
+
data.tar.gz: 60cae0a659e8044abafea282b4761ed5aac0eee84c865c5ceaeba31e4d3aaab28292e3f99bfc35eb0ff442b3175981442f29ee7fc1fb803f52256a4b94faffdc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bank_api (0.
|
4
|
+
bank_api (1.0.0)
|
5
5
|
pincers
|
6
6
|
rest-client
|
7
7
|
timezone (~> 1.0)
|
@@ -65,7 +65,7 @@ GEM
|
|
65
65
|
childprocess (~> 0.5)
|
66
66
|
rubyzip (~> 1.0)
|
67
67
|
websocket (~> 1.0)
|
68
|
-
timezone (1.2
|
68
|
+
timezone (1.3.2)
|
69
69
|
unf (0.1.4)
|
70
70
|
unf_ext
|
71
71
|
unf_ext (0.0.7.5)
|
data/lib/bank_api.rb
CHANGED
@@ -25,13 +25,13 @@ module BankApi
|
|
25
25
|
Clients::BancoDeChileCompanyClient.new(configuration).get_recent_deposits(options)
|
26
26
|
end
|
27
27
|
|
28
|
-
def self.get_bdc_account_balance(
|
29
|
-
Clients::BancoDeChileCompanyClient.new(configuration).get_account_balance(
|
28
|
+
def self.get_bdc_account_balance(options = {})
|
29
|
+
Clients::BancoDeChileCompanyClient.new(configuration).get_account_balance(options)
|
30
30
|
end
|
31
31
|
|
32
32
|
module BancoSecurity
|
33
|
-
def self.get_account_balance(
|
34
|
-
company_instance.get_balance(
|
33
|
+
def self.get_account_balance(options = {})
|
34
|
+
company_instance.get_balance(options)
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.get_recent_company_deposits(options = {})
|
@@ -34,13 +34,13 @@ module BankApi::Clients
|
|
34
34
|
].any?(&:nil?)
|
35
35
|
end
|
36
36
|
|
37
|
-
def get_balance(
|
37
|
+
def get_balance(options)
|
38
38
|
login
|
39
39
|
goto_balance
|
40
|
-
select_account(account_number)
|
40
|
+
select_account(options[:account_number])
|
41
41
|
click_fetch_balance_button
|
42
42
|
{
|
43
|
-
account_number: account_number,
|
43
|
+
account_number: options[:account_number],
|
44
44
|
available_balance: money_to_i(read_balance(:available)),
|
45
45
|
countable_balance: money_to_i(read_balance(:countable))
|
46
46
|
}
|
@@ -30,11 +30,11 @@ module BankApi::Clients::BancoSecurity
|
|
30
30
|
:security
|
31
31
|
end
|
32
32
|
|
33
|
-
def get_balance(
|
33
|
+
def get_balance(options)
|
34
34
|
login
|
35
|
-
goto_company_dashboard
|
35
|
+
goto_company_dashboard(options[:rut] || @company_rut)
|
36
36
|
goto_balance
|
37
|
-
find_account_balance(account_number)
|
37
|
+
find_account_balance(options[:account_number])
|
38
38
|
ensure
|
39
39
|
browser.close
|
40
40
|
end
|
@@ -7,6 +7,11 @@ module BankApi::Clients::BancoSecurity
|
|
7
7
|
COUNTABLE_BALANCE_COLUMN = 2
|
8
8
|
|
9
9
|
def find_account_balance(account_number)
|
10
|
+
return get_balance_from_accounts_list(account_number) if account_number
|
11
|
+
get_balance_from_account_summary
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_balance_from_accounts_list(account_number)
|
10
15
|
balance = browser.search(".cuentas-corrientes").search("tbody tr").map do |row|
|
11
16
|
cells = row.search("td")
|
12
17
|
{
|
@@ -17,19 +22,41 @@ module BankApi::Clients::BancoSecurity
|
|
17
22
|
end.find do |row|
|
18
23
|
row[:account_number] == account_number
|
19
24
|
end
|
20
|
-
|
25
|
+
validate_account_balance(balance, account_number)
|
21
26
|
balance
|
22
27
|
end
|
23
28
|
|
24
|
-
def
|
25
|
-
|
29
|
+
def get_balance_from_account_summary
|
30
|
+
available_balance = extract_balance(1)
|
31
|
+
countable_balance = extract_balance(2)
|
32
|
+
validate_summary_balance(available_balance, countable_balance)
|
33
|
+
|
34
|
+
{
|
35
|
+
available_balance: available_balance,
|
36
|
+
countable_balance: countable_balance
|
37
|
+
}
|
26
38
|
end
|
27
39
|
|
28
|
-
def
|
40
|
+
def validate_account_balance(balance, account_number)
|
29
41
|
if balance.nil?
|
30
42
|
raise BankApi::Balance::InvalidAccountNumber, "Couldn't find balance of account " +
|
31
43
|
account_number.to_s
|
32
44
|
end
|
33
45
|
end
|
46
|
+
|
47
|
+
def validate_summary_balance(available_balance, countable_balance)
|
48
|
+
if available_balance.zero? || countable_balance.zero?
|
49
|
+
raise BankApi::Balance::MissingAccountBalance, "Couldn't find balance"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def extract_balance(td_pos)
|
54
|
+
xp = "//*[@id=\"body\"]/div[1]/section/div/div/div[3]/div[2]/table/tbody/tr[1]/td[#{td_pos}]"
|
55
|
+
money_to_i(browser.search(xpath: xp).text)
|
56
|
+
end
|
57
|
+
|
58
|
+
def money_to_i(text)
|
59
|
+
text.to_s.delete(".").delete("$").delete(" ").to_i
|
60
|
+
end
|
34
61
|
end
|
35
62
|
end
|
@@ -16,9 +16,9 @@ module BankApi::Clients
|
|
16
16
|
parse_entries(get_deposits(options))
|
17
17
|
end
|
18
18
|
|
19
|
-
def get_account_balance(
|
19
|
+
def get_account_balance(options)
|
20
20
|
validate_credentials
|
21
|
-
get_balance(
|
21
|
+
get_balance(options)
|
22
22
|
end
|
23
23
|
|
24
24
|
def transfer(transfer_data)
|
@@ -51,7 +51,7 @@ module BankApi::Clients
|
|
51
51
|
raise NotImplementedError
|
52
52
|
end
|
53
53
|
|
54
|
-
def get_balance
|
54
|
+
def get_balance(_options = {})
|
55
55
|
raise NotImplementedError
|
56
56
|
end
|
57
57
|
|
data/lib/bank_api/exceptions.rb
CHANGED
data/lib/bank_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bank_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oaestay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pincers
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
196
|
rubyforge_project:
|
197
|
-
rubygems_version: 2.7.
|
197
|
+
rubygems_version: 2.7.8
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Wrapper for chilean banks
|