Class: Dinero::Bank::SouthStateBank

Inherits:
Base
  • Object
show all
Defined in:
lib/dinero/banks/south_state_bank.rb

Constant Summary collapse

LOGIN_URL =
"https://www.southstatebank.com/"
ACCOUNTS_SUMMARY_PATH =
"/accounts"
CONNECTION_TIMEOUT =
10

Instance Attribute Summary

Attributes inherited from Base

#login_url, #password, #security_questions, #timeout, #username

Instance Method Summary collapse

Methods inherited from Base

#accounts_summary_document, #authenticated?, #class_name, #connection, #establish_connection, #goto_login_page, #initialize, #login!, #screenshot_on_error, #snap, #validate!, #wait

Constructor Details

This class inherits a constructor from Dinero::Bank::Base

Instance Method Details

#account_table_rowsObject



78
79
80
# File 'lib/dinero/banks/south_state_bank.rb', line 78

def 
  accounts_summary_document.xpath("//ul[@class='AccountList-Accounts']/li/table/tbody/tr")
end

#accountsObject

extract account data from the account summary page



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/dinero/banks/south_state_bank.rb', line 83

def accounts
  return @accounts if @accounts

  # find the bricklet articles, which contains the balance data
  @accounts = .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_loginObject



63
64
65
66
67
# File 'lib/dinero/banks/south_state_bank.rb', line 63

def 
  # 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_optionsObject



8
9
10
# File 'lib/dinero/banks/south_state_bank.rb', line 8

def default_options
  { timeout: CONNECTION_TIMEOUT, login_url: LOGIN_URL }
end

#find_answer(question) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/dinero/banks/south_state_bank.rb', line 24

def find_answer question
  if q = security_questions.detect{ |qa| qa["question"] == question }
    return q["answer"]
  else
    raise "Unknown security question: #{question.inspect}"
  end
end

#goto_accounts_summary_pageObject



73
74
75
76
# File 'lib/dinero/banks/south_state_bank.rb', line 73

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?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/dinero/banks/south_state_bank.rb', line 69

def on_accounts_summary_page?
  connection.page_source =~ /List of Accounts/
end

#post_credentials!Object



57
58
59
60
61
# File 'lib/dinero/banks/south_state_bank.rb', line 57

def post_credentials!
  post_username!
  post_security_answer!
  post_password!
end

#post_password!Object



47
48
49
50
51
52
53
54
55
# File 'lib/dinero/banks/south_state_bank.rb', line 47

def post_password!
  wait.until { connection.find_element(id: "DisplayPassword") }

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

   = connection.find_element(id: "Submit")
  .click
end

#post_security_answer!Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dinero/banks/south_state_bank.rb', line 32

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!Object



12
13
14
15
16
17
18
19
20
21
22
# 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") }
     = connection.find_element(id: "desktop_hero_form_online_banking")
    username_field = .find_element(id: "desktop_hero_input_online_banking")
    username_field.send_keys username

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