Class: Dinero::Bank::CapitalOne
- Inherits:
-
Base
- Object
- Base
- Dinero::Bank::CapitalOne
show all
- Defined in:
- lib/dinero/banks/capital_one.rb
Constant Summary
collapse
- LOGIN_URL =
"https://verified.capitalone.com/sic-ui/#/esignin?Product=Card"
- ACCOUNTS_SUMMARY_PATH =
"/accounts/"
- CONNECTION_TIMEOUT =
30
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
#accounts ⇒ Object
extract account data from the account summary page
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/dinero/banks/capital_one.rb', line 53
def accounts
return @accounts if @accounts
articles = accounts_summary_document.xpath("//article").
select{|a| a.attributes["class"].value == "bricklet"}
@accounts = articles.map do |article|
prefix = article.attributes["id"].value.gsub("_bricklet", '')
name = article.xpath(".//a[@class='product_desc_link']").text
number = article.xpath(".//span[@id='#{prefix}_number']").text
balance = article.xpath(".//span[@id='#{prefix}_current_balance_amount']").text
available = first_numeric(article.xpath(".//div[@id='#{prefix}_available_credit_amount']").text)
Account.new(:credit_card, name, number, balance, available)
end
end
|
#after_successful_login ⇒ Object
32
33
34
35
36
|
# File 'lib/dinero/banks/capital_one.rb', line 32
def after_successful_login
@accounts_summary_url = connection.current_url
end
|
#default_options ⇒ Object
8
9
10
|
# File 'lib/dinero/banks/capital_one.rb', line 8
def default_options
{ timeout: CONNECTION_TIMEOUT, login_url: LOGIN_URL }
end
|
#first_numeric(value) ⇒ Object
48
49
50
|
# File 'lib/dinero/banks/capital_one.rb', line 48
def first_numeric value
value.split("\n").reject{|r| r.empty?}.first
end
|
#goto_accounts_summary_page ⇒ Object
42
43
44
45
46
|
# File 'lib/dinero/banks/capital_one.rb', line 42
def goto_accounts_summary_page
return if authenticated? && on_accounts_summary_page?
authenticated? ? connection.navigate.to(@accounts_summary_url) : login!
wait.until { connection.find_element(id: "main_content") }
end
|
#on_accounts_summary_page? ⇒ Boolean
38
39
40
|
# File 'lib/dinero/banks/capital_one.rb', line 38
def on_accounts_summary_page?
URI(connection.current_url).path == ACCOUNTS_SUMMARY_PATH
end
|
#post_credentials! ⇒ Object
27
28
29
30
|
# File 'lib/dinero/banks/capital_one.rb', line 27
def post_credentials!
post_username!
post_password!
end
|
#post_password! ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/dinero/banks/capital_one.rb', line 19
def post_password!
password_field = @signin_form.find_element(id: "password")
password_field.send_keys password
login_btn = @signin_form.find_element(id: "id-signin-submit")
login_btn.click
end
|
#post_username! ⇒ Object
12
13
14
15
16
17
|
# File 'lib/dinero/banks/capital_one.rb', line 12
def post_username!
wait.until { connection.find_element(id: "id-signin-form") }
@signin_form = connection.find_element(id: "id-signin-form")
username_field = @signin_form.find_element(id: "username")
username_field.send_keys username
end
|