bank_api 0.4.3 → 0.4.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f82ebb00cb166cfe34e69c93f6b3cebce668df5549eded7eb4df587e266ebca
4
- data.tar.gz: d8f50a971b53230c23eda1f2989fbd55b28f410e005c883ea2e4bb915baf89fc
3
+ metadata.gz: 63748c7e32a8c3a3485046be38b918a427f4d6a8833ad1ea7d6845c3bbf310b2
4
+ data.tar.gz: 62d60679b1a457f6f96a57a4f9144a4e66b4704ba361eaca69eb0d3253a99820
5
5
  SHA512:
6
- metadata.gz: 37d9bd6b17ff2f7857a07b520895dfb88d671b13f3e57169a86c362f5854b425bec318a779650ea8bbf183a60da2605217c0147afd1274a9ee96c758311ed1f5
7
- data.tar.gz: 6868f5a837c4df9135c6b1439ddb31c2c209d01db4c45a00320047fd131727bff199eccf5fa094d676e7d3b92c351cbbbb81ac9a5d5709bb8d4d848f9931aa37
6
+ metadata.gz: 39605cd234af305e2033c6c720203807a1fff43e3a462ae4d16e32cdba2a7c769c0bea4263225f428522493a85285fa6631f0417fdd98de15bf484702b96f8f9
7
+ data.tar.gz: 0231306ca60a4b307b14a9cc70ef0b515c4e920848d7be5bebc4d33e22f7ae1b8ff9df0fa108eb31b710efb2a40af4179a669870fd09f823cd8d3a171f453aea
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bank_api (0.4.3)
4
+ bank_api (0.4.4)
5
5
  pincers
6
6
  rest-client
7
7
  timezone (~> 1.0)
@@ -20,6 +20,7 @@ module BankApi::Clients
20
20
  @bdc_company_rut = config.bdc_company_rut
21
21
  @bdc_user_rut = config.bdc_user_rut
22
22
  @bdc_password = config.bdc_password
23
+ @bdc_account = config.bdc_account
23
24
  super
24
25
  end
25
26
 
@@ -75,11 +76,21 @@ module BankApi::Clients
75
76
 
76
77
  def select_deposits_range
77
78
  browser.search('input[name=initDate]').set(deposit_range[:start])
79
+ first_account = browser.search("select[name=ctaCorriente] option").find do |account|
80
+ account.value.include? @bdc_account
81
+ end.value
82
+ browser.search("select[name=ctaCorriente]").set by_value: first_account
78
83
  browser.search('#consultar').click
79
84
  end
80
85
 
86
+ def validate_banchile_status!
87
+ unless browser.search(".textoerror:contains('no podemos atenderle')").none?
88
+ raise "Banchile is down"
89
+ end
90
+ end
91
+
81
92
  def any_deposits?
82
- browser.search('table#sin_datos').count.zero?
93
+ browser.search('table#sin_datos').none?
83
94
  end
84
95
 
85
96
  def total_results
@@ -88,14 +99,19 @@ module BankApi::Clients
88
99
  end
89
100
 
90
101
  def deposits_from_txt
102
+ validate_banchile_status!
91
103
  return [] unless any_deposits?
92
104
  response = RestClient::Request.execute(
93
105
  url: COMPANY_DEPOSITS_TXT_URL, method: :post, headers: session_headers,
94
106
  payload: deposits_params(deposit_range[:start], deposit_range[:end]), verify_ssl: false
95
107
  )
108
+ raise "Banchile is down" if response.body.include? "no podemos atenderle"
96
109
 
97
110
  transactions = split_transactions(response.body)
98
111
  format_transactions(transactions)
112
+ rescue => e
113
+ validate_banchile_status!
114
+ raise e
99
115
  end
100
116
 
101
117
  def split_transactions(transactions_str)
@@ -1,11 +1,12 @@
1
1
  module BankApi
2
2
  class Configuration
3
- attr_accessor :bdc_user_rut, :bdc_password, :bdc_company_rut, :days_to_check
3
+ attr_accessor :bdc_user_rut, :bdc_password, :bdc_company_rut, :bdc_account, :days_to_check
4
4
 
5
5
  def initialize
6
6
  @bdc_user_rut = nil
7
7
  @bdc_password = nil
8
8
  @bdc_company_rut = nil
9
+ @bdc_account = nil
9
10
 
10
11
  @days_to_check = 6
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module BankApi
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
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.3
4
+ version: 0.4.4
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-08 00:00:00.000000000 Z
11
+ date: 2018-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pincers