Class: Dinero::Bank::Sdccu

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

Overview

San Diego County Credit Union

Constant Summary collapse

LOGIN_URL =
"https://internetbranch.sdccu.com/SDCCU/Login.aspx"
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

Constructor Details

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

Instance Method Details

#account_rows(table, type) ⇒ Object



84
85
86
87
# File 'lib/dinero/banks/sdccu.rb', line 84

def  table, type
  rows = table.xpath(".//tr").map{|m| m.xpath(".//td").map{|m| m.text.strip}}
  rows.select{|s| s.size == 7}.map{|m| m.reject(&:empty?) << type}
end

#account_table_rowsObject



89
90
91
# File 'lib/dinero/banks/sdccu.rb', line 89

def 
  (bank_accounts_table, :bank) + (loan_accounts_table, :loan)
end

#account_tablesObject



72
73
74
# File 'lib/dinero/banks/sdccu.rb', line 72

def 
  accounts_summary_document.xpath("//div[@id='accountBalancesContainer_accountBalancesModule_accountList']//table")
end

#accountsObject

extract account data from the account summary page



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/dinero/banks/sdccu.rb', line 94

def accounts
  return @accounts if @accounts

  @accounts = .map do |row|
    acct_type = row.pop
    number = row.shift
    name = row.shift
    balance = row.shift.scan(NUMERIC_REGEXP).join
    available = acct_type == :loan ? "0.0" : balance
    .new(acct_type, name, number, balance, available)
  end
end

#after_successful_loginObject



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

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

#bank_accounts_tableObject



76
77
78
# File 'lib/dinero/banks/sdccu.rb', line 76

def bank_accounts_table
  [0]
end

#default_optionsObject



9
10
11
# File 'lib/dinero/banks/sdccu.rb', line 9

def default_options
  { timeout: CONNECTION_TIMEOUT, login_url:  }
end

#goto_accounts_summary_pageObject



67
68
69
70
# File 'lib/dinero/banks/sdccu.rb', line 67

def goto_accounts_summary_page
  return if authenticated? && on_accounts_summary_page?
  authenticated? ? connection.navigate.to(@accounts_summary_url) : login!
end

#loan_accounts_tableObject



80
81
82
# File 'lib/dinero/banks/sdccu.rb', line 80

def loan_accounts_table
  [1]
end

#on_accounts_summary_page?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/dinero/banks/sdccu.rb', line 63

def on_accounts_summary_page?
  connection.page_source =~ /Account Balances/
end

#post_credentials!Object



51
52
53
54
55
# File 'lib/dinero/banks/sdccu.rb', line 51

def post_credentials!
  post_username!
  post_password!
  post_security_answer!
end

#post_password!Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dinero/banks/sdccu.rb', line 24

def post_password!
  screenshot_on_error do
    wait.until { connection.find_element(id: "ctlSignon_txtPassword") }

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

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

#post_security_answer!Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/dinero/banks/sdccu.rb', line 36

def post_security_answer!
  return if on_accounts_summary_page?
  screenshot_on_error do
    wait.until { connection.find_element(id: "lblChallengeQuestion") }
    question_text = connection.find_element(id: "lblChallengeQuestion").text
    answer = find_answer question_text

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

    submit_button = logon_form.find_element(id:"btnSubmitAnswer")
    submit_button.click
  end
end

#post_username!Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/dinero/banks/sdccu.rb', line 13

def post_username!
  screenshot_on_error do
    wait.until { connection.find_element(id: "ctlSignon_txtUserID") }
    username_field = connection.find_element(id: "ctlSignon_txtUserID")
    username_field.send_keys username

    submit_button = connection.find_element(id: "ctlSignon_btnNext")
    submit_button.click
  end
end