Class: Dinero::Bank::SouthStateBank
- Inherits:
-
Base
- Object
- Base
- Dinero::Bank::SouthStateBank
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
Instance Method Details
#account_table_rows ⇒ Object
78
79
80
|
# File 'lib/dinero/banks/south_state_bank.rb', line 78
def account_table_rows
accounts_summary_document.xpath("//ul[@class='AccountList-Accounts']/li/table/tbody/tr")
end
|
#accounts ⇒ Object
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
@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 ⇒ Object
63
64
65
66
67
|
# File 'lib/dinero/banks/south_state_bank.rb', line 63
def after_successful_login
@accounts_summary_url = connection.current_url
end
|
#default_options ⇒ Object
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_page ⇒ Object
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
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
login_btn = connection.find_element(id: "Submit")
login_btn.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") }
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
|