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, #find_answer, #goto_login_page, #initialize, #login!, #screenshot_on_error, #snap, #validate!, #wait
Instance Method Details
#account_table_rows ⇒ Object
70
71
72
|
# 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 ⇒ Object
extract account data from the account summary page
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/dinero/banks/south_state_bank.rb', line 75
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
55
56
57
58
59
|
# File 'lib/dinero/banks/south_state_bank.rb', line 55
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
|
#goto_accounts_summary_page ⇒ Object
65
66
67
68
|
# 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? ⇒ Boolean
61
62
63
|
# File 'lib/dinero/banks/south_state_bank.rb', line 61
def on_accounts_summary_page?
connection.page_source =~ /List of Accounts/
end
|
#post_credentials! ⇒ Object
49
50
51
52
53
|
# File 'lib/dinero/banks/south_state_bank.rb', line 49
def post_credentials!
post_username!
post_security_answer!
post_password!
end
|
#post_password! ⇒ Object
39
40
41
42
43
44
45
46
47
|
# 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! ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# 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! ⇒ 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
|