bank_api 0.2.5 → 0.2.6
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 +5 -5
- data/Gemfile.lock +7 -2
- data/bank_api.gemspec +1 -0
- data/lib/bank_api/clients/banco_security/company_client.rb +1 -0
- data/lib/bank_api/clients/banco_security/concerns/deposits.rb +47 -8
- data/lib/bank_api/configs/banco_security.rb +2 -1
- data/lib/bank_api/exceptions.rb +4 -0
- data/lib/bank_api/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4546cdde255d5e40b6106c68d8a8dec2c4aad0ca
|
4
|
+
data.tar.gz: 9113856380204a99a5a75faf2101336ab1e6564c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97ed3117c45055b44b0f3ab5e38279aaff618f9812ab3db72d3238b9edc0e4339da9e21b822b207ee705b9030cc4a84fdfa0dc668ef3a603d876e4804974bb93
|
7
|
+
data.tar.gz: e9e3772328998873e562a1ea96fbcbb0df15435c1033d2c130d767b6fbeb897449cbed47c48c88ab8250e54ef0c62a4ae5ad639f9718106d0ac54e791f355592
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bank_api (0.2.
|
4
|
+
bank_api (0.2.6)
|
5
5
|
pincers
|
6
6
|
timezone (~> 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
|
11
|
+
byebug (10.0.2)
|
12
|
+
childprocess (0.8.0)
|
12
13
|
ffi (~> 1.0, >= 1.0.11)
|
13
14
|
coderay (1.1.2)
|
14
15
|
diff-lcs (1.3)
|
@@ -23,6 +24,9 @@ GEM
|
|
23
24
|
pry (0.11.3)
|
24
25
|
coderay (~> 1.1.0)
|
25
26
|
method_source (~> 0.9.0)
|
27
|
+
pry-byebug (3.6.0)
|
28
|
+
byebug (~> 10.0)
|
29
|
+
pry (~> 0.10)
|
26
30
|
rake (10.5.0)
|
27
31
|
rspec (3.7.0)
|
28
32
|
rspec-core (~> 3.7.0)
|
@@ -52,6 +56,7 @@ DEPENDENCIES
|
|
52
56
|
bank_api!
|
53
57
|
bundler (~> 1.16)
|
54
58
|
pry
|
59
|
+
pry-byebug
|
55
60
|
rake (~> 10.0)
|
56
61
|
rspec (~> 3.0)
|
57
62
|
|
data/bank_api.gemspec
CHANGED
@@ -7,7 +7,6 @@ module BankApi::Clients::BancoSecurity
|
|
7
7
|
AMOUNT_COLUMN = 5
|
8
8
|
|
9
9
|
NUMBER_OF_COLUMNS = 7
|
10
|
-
DEFAULT_PAGINATION = 30
|
11
10
|
|
12
11
|
def select_deposits_range
|
13
12
|
browser.search('.BusquedaPorDefectoRecibida a:contains("búsqueda avanzada")').click
|
@@ -15,14 +14,19 @@ module BankApi::Clients::BancoSecurity
|
|
15
14
|
browser.search('#datePickerInicioRecibidas').set deposit_range[:start]
|
16
15
|
browser.search('#datePickerFinRecibido').set deposit_range[:end]
|
17
16
|
browser.search('.ContenedorSubmitRecibidas .btn_buscar').click
|
17
|
+
set_page_size
|
18
18
|
wait_for_deposits_fetch
|
19
19
|
end
|
20
20
|
|
21
21
|
def wait_for_deposits_fetch
|
22
22
|
goto_frame query: '#mainFrame'
|
23
23
|
goto_frame query: 'iframe[name="central"]', should_reset: false
|
24
|
-
|
25
|
-
wait('.k-loading-image') { browser.search('.k-loading-image').
|
24
|
+
wait('.k-loading-image') { browser.search('.k-loading-image').any? }
|
25
|
+
wait('.k-loading-image') { browser.search('.k-loading-image').none? }
|
26
|
+
end
|
27
|
+
|
28
|
+
def wait_for_next_page(last_seen_deposit)
|
29
|
+
wait(".k-pager-info") { last_seen_deposit < last_deposit_in_current_page }
|
26
30
|
end
|
27
31
|
|
28
32
|
def extract_deposits_from_html
|
@@ -31,12 +35,17 @@ module BankApi::Clients::BancoSecurity
|
|
31
35
|
return deposits unless any_deposits?
|
32
36
|
|
33
37
|
deposits += deposits_from_page
|
34
|
-
|
35
|
-
((
|
38
|
+
last_seen_deposit = last_deposit_in_current_page
|
39
|
+
((total_deposits - 1) / @page_size).times do
|
36
40
|
goto_next_page
|
41
|
+
wait_for_next_page(last_seen_deposit)
|
42
|
+
last_seen_deposit = last_deposit_in_current_page
|
43
|
+
|
37
44
|
deposits += deposits_from_page
|
38
45
|
end
|
39
46
|
|
47
|
+
validate_deposits(deposits, last_seen_deposit)
|
48
|
+
|
40
49
|
deposits.sort_by { |d| d[:date] }
|
41
50
|
end
|
42
51
|
|
@@ -58,6 +67,28 @@ module BankApi::Clients::BancoSecurity
|
|
58
67
|
deposits
|
59
68
|
end
|
60
69
|
|
70
|
+
def set_page_size
|
71
|
+
browser.search('[aria-owns="pagerSettingRecibidas_listbox"]').click
|
72
|
+
sleep 0.1
|
73
|
+
browser.search('.k-animation-container.km-popup li').find do |li|
|
74
|
+
li.text == @page_size.to_s
|
75
|
+
end.click
|
76
|
+
wait('.k-loading-image') { browser.search('.k-loading-image').any? }
|
77
|
+
wait('.k-loading-image') { browser.search('.k-loading-image').none? }
|
78
|
+
end
|
79
|
+
|
80
|
+
def last_deposit_in_current_page
|
81
|
+
pages_info = wait(".k-pager-info")
|
82
|
+
matches = pages_info.text.match(/(\d+)[a-z\s-]+(\d+)[a-z\s-]+(\d+)/)
|
83
|
+
matches[2].to_i
|
84
|
+
end
|
85
|
+
|
86
|
+
def total_deposits
|
87
|
+
pages_info = wait(".k-pager-info")
|
88
|
+
matches = pages_info.text.match(/(\d+)[a-z\s-]+(\d+)[a-z\s-]+(\d+)/)
|
89
|
+
matches[3].to_i
|
90
|
+
end
|
91
|
+
|
61
92
|
def goto_next_page
|
62
93
|
browser.search('#gridPrincipalRecibidas a.k-link[title="Go to the next page"]').click
|
63
94
|
end
|
@@ -78,9 +109,17 @@ module BankApi::Clients::BancoSecurity
|
|
78
109
|
).none?
|
79
110
|
end
|
80
111
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
112
|
+
def validate_deposits(deposits, last_seen_deposit)
|
113
|
+
total_deposits_ = total_deposits
|
114
|
+
unless deposits.count == total_deposits_
|
115
|
+
raise BankApi::Deposit::QuantityError, "Expected #{total_deposits_} deposits," +
|
116
|
+
" got #{deposits.count}."
|
117
|
+
end
|
118
|
+
|
119
|
+
unless last_seen_deposit == total_deposits_
|
120
|
+
raise BankApi::Deposit::PaginationError, "Expected to fetch #{total_deposits_} deposits," +
|
121
|
+
" the last seen deposit was nº #{last_seen_deposit}."
|
122
|
+
end
|
84
123
|
end
|
85
124
|
end
|
86
125
|
end
|
@@ -2,13 +2,14 @@ require 'bank_api/values/dynamic_card'
|
|
2
2
|
|
3
3
|
module BankApi::Configs
|
4
4
|
class BancoSecurity
|
5
|
-
attr_accessor :user_rut, :password, :company_rut, :dynamic_card_entries
|
5
|
+
attr_accessor :user_rut, :password, :company_rut, :page_size, :dynamic_card_entries
|
6
6
|
|
7
7
|
def initialize
|
8
8
|
@user_rut = nil
|
9
9
|
@password = nil
|
10
10
|
@company_rut = nil
|
11
11
|
@dynamic_card_entries = nil
|
12
|
+
@page_size = 30
|
12
13
|
end
|
13
14
|
|
14
15
|
def dynamic_card
|
data/lib/bank_api/exceptions.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
module BankApi
|
2
2
|
class MissingCredentialsError < StandardError; end
|
3
|
+
module Deposit
|
4
|
+
class QuantityError < StandardError; end
|
5
|
+
class PaginationError < StandardError; end
|
6
|
+
end
|
3
7
|
module Transfer
|
4
8
|
class InvalidBank < StandardError; end
|
5
9
|
class InvalidAccountType < StandardError; end
|
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.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oaestay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pincers
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
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'
|
97
111
|
description: Wrapper for chilean banks
|
98
112
|
email:
|
99
113
|
- oaestay@uc.cl
|
@@ -150,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
164
|
version: '0'
|
151
165
|
requirements: []
|
152
166
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.5.2
|
154
168
|
signing_key:
|
155
169
|
specification_version: 4
|
156
170
|
summary: Wrapper for chilean banks
|