Class: Banks::BankOfAmerica

Inherits:
Bank
  • Object
show all
Defined in:
lib/banks/bofa.rb

Overview

Note: If you are running the script for the first time, you need to go online

and validate your computer by answering security questions.

TODO: Ask the user to enter security questions.

Instance Method Summary collapse

Instance Method Details

#get_data(user, password) ⇒ Object

Returns all accounts with all transactions. Currently supports Credit and Debit accounts.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/banks/bofa.rb', line 8

def get_data (user, password)
  # Connect
  browser = ::Watir::Browser.new #:"phantomjs"
  browser.goto 'http://bankofamerica.com'
  browser.text_field(:id => 'onlineId1').set user
  browser.text_field(:id => 'passcode1').set password
  browser.button(:id => 'hp-sign-in-btn').click

  # Wait until logged in.
  # Watir wait did not work on Windows, so we do a hack.
  # http://watirwebdriver.com/waiting/
  # http://stackoverflow.com/questions/3504322/watir-webdriver-wait-for-page-load
  until browser.ul(:class=>"AccountItems").exists? do sleep 1 end

  # Get accounts
  accounts = get_accounts browser.html

  accounts.each do ||
    browser.goto "https://secure.bankofamerica.com" + .link
    transactions = nil
    if .type == Account::DEBIT
      transactions = get_debit_transactions browser.html
    elsif .type == Account::CREDIT
      transactions = get_credit_transactions browser
    end
    .transactions = transactions
  end

  # Clean-up
  browser.close

  # Return accounts.
  accounts
end