bank_api 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5470f8a6efd79fb2a6c682f8bb1f20377b8da9717a8d142ec69e6585aabebb4f
4
- data.tar.gz: c1db9695592d8f0e7f0c72fcd2eebf749295f6ff0d4b93c9621fef4b9ef2e203
3
+ metadata.gz: 3ee63798e44803986aa2a2a9428500311aaddf896d9d9d0dd537b12705be2cfe
4
+ data.tar.gz: d2449dd880b2056573e3977aefc1610e82e5a8f59a1f66814aa9f7bcb4377c41
5
5
  SHA512:
6
- metadata.gz: ff3ff90e99eff53acdaf34cecc01770c9019c85a87f5642ffb3a4a053a45c14adedbeccb5334a01cc00f44cb01fb904e36695fa37cc39616fd4c51b79023df33
7
- data.tar.gz: 9e8c48bbb270a0b62ffad7b4a6482f15e7c2549dfb4f4060d3de141b6b55bc7e261e4c372701e6f72a4a8e9d223a4d8746b983c9ce5dbd2639e8e12138d79513
6
+ metadata.gz: 45e2cbbff9ffd1e26903c8c79566b141761460d5b4190ca05be78d6e6e71b92a4ac9122ac318380bb0dd72598f50cc496c018e3ff725c3b83addc5c8bdcc2641
7
+ data.tar.gz: 17a5e5827d454eec7f0e892a1173b117ab39acac44625a50779fe8569485bad294bdfa317de5b8ac4e32ebbb005af667b185eb4ad8ff214eb860afdc97467b35
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bank_api (0.6.1)
4
+ bank_api (0.6.2)
5
5
  pincers
6
6
  rest-client
7
7
  timezone (~> 1.0)
@@ -39,21 +39,27 @@ module BankApi::Clients
39
39
  ].any?(&:nil?)
40
40
  end
41
41
 
42
- def get_balance
42
+ def get_balance(account_number)
43
43
  login
44
44
  goto_balance
45
- select_account
45
+ select_account(account_number)
46
46
  click_fetch_balance_button
47
- money_to_i read_balance
47
+ {
48
+ account_number: account_number,
49
+ available_balance: money_to_i(read_balance(:available)),
50
+ countable_balance: money_to_i(read_balance(:countable))
51
+ }
52
+ ensure
53
+ browser.close
48
54
  end
49
55
 
50
56
  def goto_balance
51
57
  browser.goto COMPANY_CC_BALANCE_URL
52
58
  end
53
59
 
54
- def select_account
60
+ def select_account(account_number)
55
61
  first_account = browser.search("select[name=cuenta] option").find do |account|
56
- account.value.include? @bdc_account
62
+ account.value.include? account_number
57
63
  end.value
58
64
  browser.search("select[name=cuenta]").set by_value: first_account
59
65
  end
@@ -66,8 +72,14 @@ module BankApi::Clients
66
72
  text.delete(".").delete("$").delete(" ").to_i
67
73
  end
68
74
 
69
- def read_balance
70
- browser.search('table.detalleSaldosMov tr:nth-child(2) > td.aRight.bold').text
75
+ def read_balance(balance_kind)
76
+ return '' unless [:available, :countable].include? balance_kind
77
+
78
+ if balance_kind == :available
79
+ return browser.search('table.detalleSaldosMov tr:nth-child(2) > td.aRight.bold').text
80
+ end
81
+
82
+ browser.search('table.detalleSaldosMov tr:first-child > td.aRight.bold').text
71
83
  end
72
84
 
73
85
  def get_deposits(_options = {})
@@ -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(account_number)
20
20
  validate_credentials
21
- get_balance
21
+ get_balance(account_number)
22
22
  end
23
23
 
24
24
  def transfer(transfer_data)
@@ -1,3 +1,3 @@
1
1
  module BankApi
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
data/lib/bank_api.rb CHANGED
@@ -25,8 +25,8 @@ module BankApi
25
25
  Clients::BancoDeChileCompanyClient.new(configuration).get_recent_deposits
26
26
  end
27
27
 
28
- def self.get_bdc_company_balance
29
- Clients::BancoDeChileCompanyClient.new(configuration).get_account_balance
28
+ def self.get_bdc_account_balance(account_number)
29
+ Clients::BancoDeChileCompanyClient.new(configuration).get_account_balance(account_number)
30
30
  end
31
31
 
32
32
  module BancoSecurity
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bank_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - oaestay