class Dinero::Bank::SouthStateBank

Constants

ACCOUNTS_SUMMARY_PATH
CONNECTION_TIMEOUT
LOGIN_URL

Public Instance Methods

account_table_rows() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 70
def account_table_rows
  accounts_summary_document.xpath("//ul[@class='AccountList-Accounts']/li/table/tbody/tr")
end
accounts() click to toggle source

extract account data from the account summary page

# File lib/dinero/banks/south_state_bank.rb, line 75
def accounts
  return @accounts if @accounts

  # find the bricklet articles, which contains the balance data
  @accounts = account_table_rows.map do |row|
    data = row.xpath(".//td").map(&:text)
    number = data.shift
    name = data.shift
    balance = data.pop.scan(NUMERIC_REGEXP).join
    available = data.pop.scan(NUMERIC_REGEXP).join
    available = balance if available.empty?
    Account.new(:bank, name, number, balance, available)
  end
end
after_successful_login() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 55
def after_successful_login
  # the subdomain frequently changes, so capture the actual URL
  # so we can return to the page if necessary.
  @accounts_summary_url = connection.current_url
end
default_options() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 8
def default_options
  { timeout: CONNECTION_TIMEOUT, login_url: LOGIN_URL }
end
goto_accounts_summary_page() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 65
def goto_accounts_summary_page
  return if authenticated? && on_accounts_summary_page?
  authenticated? ? connection.navigate.to(@accounts_summary_url) : login!
end
on_accounts_summary_page?() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 61
def on_accounts_summary_page?
  connection.page_source =~ /List of Accounts/
end
post_credentials!() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 49
def post_credentials!
  post_username!
  post_security_answer!
  post_password!
end
post_password!() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 39
def post_password!
  wait.until { connection.find_element(id: "DisplayPassword") }

  password_field = connection.find_element(id: "DisplayPassword")
  password_field.send_keys password

  login_btn = connection.find_element(id: "Submit")
  login_btn.click
end
post_security_answer!() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 24
def post_security_answer!
  screenshot_on_error do
    wait.until { connection.find_element(id: "nav2t") }
    logon_form = connection.find_element(id: "Logon")
    question_text = logon_form.find_element(xpath: ".//table/tbody/tr/td").text
    answer = find_answer question_text

    answer_field = logon_form.find_element(id: "QuestionAnswer")
    answer_field.send_keys answer

    submit_button = logon_form.find_element(id:"Submit")
    submit_button.click
  end
end
post_username!() click to toggle source
# File lib/dinero/banks/south_state_bank.rb, line 12
def post_username!
  screenshot_on_error do
    wait.until { connection.find_element(id: "desktop-splash-login") }
    login_form = connection.find_element(id: "desktop_hero_form_online_banking")
    username_field = login_form.find_element(id: "desktop_hero_input_online_banking")
    username_field.send_keys username

    submit_button = login_form.find_element(xpath: ".//input[@type='submit']")
    submit_button.click
  end
end