bank_api 0.7.6 → 0.7.7
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/clients/banco_security/concerns/deposits.rb +45 -7
- 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: 94b0f3f7f91bbb4833ef3c4b95773116f8dc0979a045254e7f595b6b4143020a
|
4
|
+
data.tar.gz: f18540be2dde9b842bbe2e0594d6ff9d3222739327039a2e3e0c09565df783d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6e54aaa6d7a9cbf0569cc2e2d50eef305df7d2a25ce14be34077bf41108d2f7159e9f9845dfc001a0f484a7d383794d4fa946819a5631a3cd37de6eb18f68aa
|
7
|
+
data.tar.gz: 8b50fb49d428367b92e3bfe42a19c37e8c962c9a8adc70b9d73c834fbf9d284cb33e54ad540eaf596757b91a393022ba4d95fa468fb56b1e977ec7d99716fa8a
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
require 'rest-client'
|
2
3
|
|
3
4
|
module BankApi::Clients::BancoSecurity
|
4
5
|
module Deposits
|
6
|
+
SESSION_VALIDATION = "https://www.bancosecurity.cl/empresas/SessionValidation.asp"
|
7
|
+
|
5
8
|
def select_deposits_range
|
6
9
|
browser.search('.BusquedaPorDefectoRecibida a:contains("búsqueda avanzada")').click
|
7
10
|
browser.search('#RadioEntreFechasRecibido').click
|
@@ -33,13 +36,28 @@ module BankApi::Clients::BancoSecurity
|
|
33
36
|
end
|
34
37
|
|
35
38
|
def deposits_from_txt
|
36
|
-
wait("") { any_deposits? }
|
37
39
|
raise BankApi::Deposit::FetchError, "Couldn't fetch deposits" unless any_deposits?
|
40
|
+
setup_authentication
|
38
41
|
download = browser.download(deposits_txt_url)
|
39
42
|
transactions = download.content.split("\n").drop(1).map { |r| r.split("|") }
|
43
|
+
if transactions.empty?
|
44
|
+
raise BankApi::Deposit::FetchError, "Couldn't fetch deposits, received #{download.content}"
|
45
|
+
end
|
40
46
|
format_transactions(transactions)
|
41
47
|
end
|
42
48
|
|
49
|
+
def setup_authentication
|
50
|
+
response = RestClient::Request.execute(
|
51
|
+
url: SESSION_VALIDATION, method: :post, headers: session_headers
|
52
|
+
)
|
53
|
+
new_cookies = response.headers[:set_cookie].first.delete(" ").split(";").map do |a|
|
54
|
+
a.split("=")
|
55
|
+
end
|
56
|
+
new_cookies.each do |key, value|
|
57
|
+
selenium_browser.manage.add_cookie(name: key, value: value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
43
61
|
def deposits_from_account_details
|
44
62
|
data = browser.download(
|
45
63
|
deposits_account_details_url
|
@@ -92,13 +110,33 @@ module BankApi::Clients::BancoSecurity
|
|
92
110
|
end
|
93
111
|
end
|
94
112
|
|
113
|
+
def session_headers
|
114
|
+
{
|
115
|
+
"Origin" => "https://www.bancosecurity.cl",
|
116
|
+
"Accept-Encoding" => "gzip, deflate, br",
|
117
|
+
"Accept-Language" => "en-US,en;q=0.9",
|
118
|
+
"User-Agent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 " +
|
119
|
+
"(KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36",
|
120
|
+
"Accept" => "*/*",
|
121
|
+
"Referer" => "https://www.bancosecurity.cl/ConvivenciaEmpresas/CartolasTEF/Home?" + "
|
122
|
+
tipoTransaccion=Recibidas",
|
123
|
+
"X-Requested-With" => "XMLHttpRequest",
|
124
|
+
"Connection" => "keep-alive",
|
125
|
+
"Content-Length" => "0",
|
126
|
+
"Cookie" => cookies
|
127
|
+
}
|
128
|
+
end
|
129
|
+
|
130
|
+
def cookies
|
131
|
+
selenium_browser.manage.all_cookies.map do |cookie|
|
132
|
+
"#{cookie[:name]}=#{cookie[:value]}"
|
133
|
+
end.join("; ")
|
134
|
+
end
|
135
|
+
|
95
136
|
def deposits_txt_url
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
"https://www.bancosecurity.cl/ConvivenciaEmpresas/CartolasTEF/Download/" +
|
100
|
-
"CrearTxTRecibidas?numeroCuenta=#{account_number}&monto=0&" +
|
101
|
-
"fechaInicio=#{start_}&fechaFin=#{end_}&estado=1"
|
137
|
+
selenium_browser.execute_script("console.log(DescargarDocumentoTxtRecibidas)")
|
138
|
+
log = selenium_browser.manage.logs.get(:browser).last
|
139
|
+
/url = '(.*)';/.match(log.message).captures.first
|
102
140
|
end
|
103
141
|
|
104
142
|
def deposits_account_details_url
|
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.7.
|
4
|
+
version: 0.7.7
|
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-09 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.7
|
198
198
|
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Wrapper for chilean banks
|