bank_api 0.6.2 → 0.7.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/Gemfile.lock +1 -1
- data/lib/bank_api.rb +2 -2
- data/lib/bank_api/clients/banco_de_chile_company_client.rb +59 -16
- data/lib/bank_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c662404a8d0dc38f26dfca622c9a22437b6db2fd7afc97e654cf66adb2edd02
|
4
|
+
data.tar.gz: 5cefd91e473f411bed2637111e18a63fa2b185c6f64c9aa1c03a8e0d270bd701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c34c055bf07cb81e49c5624ac43c68701e4c36f42ed20d39daaecd4a2639e84bfdaa59bab7c3e52e506475527285394d49a02f02a4e945f3f6709b3d70ae3f4
|
7
|
+
data.tar.gz: 1ba1ace8c489633af961c19dacc9b13d4f8801bfdbfcc11ea52c75fb8473f7588b14d0c09890221476bfa8b3ab872acfd437f1e434736f6e0bd82f163d2c02e0
|
data/Gemfile.lock
CHANGED
data/lib/bank_api.rb
CHANGED
@@ -21,8 +21,8 @@ module BankApi
|
|
21
21
|
yield(configuration)
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.get_bdc_recent_company_deposits
|
25
|
-
Clients::BancoDeChileCompanyClient.new(configuration).get_recent_deposits
|
24
|
+
def self.get_bdc_recent_company_deposits(options = {})
|
25
|
+
Clients::BancoDeChileCompanyClient.new(configuration).get_recent_deposits(options)
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.get_bdc_account_balance(account_number)
|
@@ -8,15 +8,9 @@ module BankApi::Clients
|
|
8
8
|
COMPANY_LOGIN_URL = 'https://www.empresas.bancochile.cl/cgi-bin/navega?pagina=enlinea/login_fus'
|
9
9
|
COMPANY_DEPOSITS_URL = 'https://www.empresas.bancochile.cl/GlosaInternetEmpresaRecibida/ConsultaRecibidaAction.do'
|
10
10
|
COMPANY_DEPOSITS_TXT_URL = 'https://www.empresas.bancochile.cl/GlosaInternetEmpresaRecibida/RespuestaConsultaRecibidaAction.do'
|
11
|
+
COMPANY_ACCOUNT_DEPOSITS_URL = 'https://www.empresas.bancochile.cl/CCOLSaldoMovimientosWEB/selectorCuentas.do?accion=initSelectorCuentas&cuenta=001642711701&moneda=CTD#page=page-1'
|
11
12
|
COMPANY_CC_BALANCE_URL = 'https://www.empresas.bancochile.cl/CCOLDerivadorWEB/selectorCuentas.do?accion=initSelectorCuentas&opcion=saldos&moduloProducto=CC'
|
12
13
|
|
13
|
-
DATE_COLUMN = 0
|
14
|
-
RUT_COLUMN = 4
|
15
|
-
AMOUNT_COLUMN = 6
|
16
|
-
STATE_COLUMN = 7
|
17
|
-
|
18
|
-
NUMBER_OF_COLUMNS = 9
|
19
|
-
|
20
14
|
def initialize(config = BankApi::Configuration.new)
|
21
15
|
@bdc_company_rut = config.bdc_company_rut
|
22
16
|
@bdc_user_rut = config.bdc_user_rut
|
@@ -82,16 +76,29 @@ module BankApi::Clients
|
|
82
76
|
browser.search('table.detalleSaldosMov tr:first-child > td.aRight.bold').text
|
83
77
|
end
|
84
78
|
|
85
|
-
def get_deposits(
|
79
|
+
def get_deposits(options = {})
|
86
80
|
login
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
81
|
+
|
82
|
+
if options[:source] == :account_details
|
83
|
+
return get_deposits_from_balance_section
|
84
|
+
end
|
85
|
+
|
86
|
+
get_deposits_from_transfers_section
|
91
87
|
ensure
|
92
88
|
browser.close
|
93
89
|
end
|
94
90
|
|
91
|
+
def get_deposits_from_balance_section
|
92
|
+
goto_account_deposits
|
93
|
+
account_deposits_from_txt
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_deposits_from_transfers_section
|
97
|
+
goto_deposits
|
98
|
+
select_deposits_range
|
99
|
+
deposits_from_txt
|
100
|
+
end
|
101
|
+
|
95
102
|
def login
|
96
103
|
goto_login_url
|
97
104
|
set_login_values
|
@@ -114,10 +121,22 @@ module BankApi::Clients
|
|
114
121
|
browser.search('.btn_amarillodegrade').click
|
115
122
|
end
|
116
123
|
|
124
|
+
def goto_account_deposits
|
125
|
+
browser.goto COMPANY_ACCOUNT_DEPOSITS_URL
|
126
|
+
end
|
127
|
+
|
117
128
|
def goto_deposits
|
118
129
|
browser.goto COMPANY_DEPOSITS_URL
|
119
130
|
end
|
120
131
|
|
132
|
+
def account_deposits_from_txt
|
133
|
+
url = browser.search("#expoDato_child > a:nth-child(3)").attribute(:href)
|
134
|
+
result = browser.download(url)
|
135
|
+
.content.encode("UTF-8", "iso-8859-3")
|
136
|
+
.delete("\r").split("\n").drop(2)
|
137
|
+
format_account_transactions(result)
|
138
|
+
end
|
139
|
+
|
121
140
|
def select_deposits_range
|
122
141
|
browser.search('input[name=initDate]').set(deposit_range[:start])
|
123
142
|
first_account = browser.search("select[name=ctaCorriente] option").find do |account|
|
@@ -160,20 +179,44 @@ module BankApi::Clients
|
|
160
179
|
|
161
180
|
def split_transactions(transactions_str)
|
162
181
|
transactions_str.delete("\r").split("\n").drop(1).map { |r| r.split(";") }.select do |t|
|
163
|
-
t[
|
182
|
+
t[7] == "Aprobada"
|
164
183
|
end
|
165
184
|
end
|
166
185
|
|
167
186
|
def format_transactions(transactions)
|
168
187
|
transactions.map do |t|
|
169
188
|
{
|
170
|
-
|
171
|
-
|
172
|
-
|
189
|
+
client: format_client_name(t[3]),
|
190
|
+
rut: t[4],
|
191
|
+
date: Date.parse(t[0]),
|
192
|
+
time: nil,
|
193
|
+
amount: t[6].to_i
|
194
|
+
}
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def format_account_transactions(transactions)
|
199
|
+
transactions.inject([]) do |memo, t|
|
200
|
+
parts = t.split(";")
|
201
|
+
amount = parts[3].to_i
|
202
|
+
next memo if amount.zero?
|
203
|
+
|
204
|
+
memo << {
|
205
|
+
client: format_client_name(parts[1]),
|
206
|
+
rut: nil,
|
207
|
+
date: Date.parse(parts[0]),
|
208
|
+
time: nil,
|
209
|
+
amount: amount
|
173
210
|
}
|
211
|
+
|
212
|
+
memo
|
174
213
|
end
|
175
214
|
end
|
176
215
|
|
216
|
+
def format_client_name(name)
|
217
|
+
name.to_s.split("DE:").last.to_s.strip
|
218
|
+
end
|
219
|
+
|
177
220
|
def deposits_params(from_date, to_date)
|
178
221
|
{
|
179
222
|
'accion' => 'exportarTxtOperaciones',
|
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: 0.7.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-09-
|
11
|
+
date: 2018-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pincers
|