Class: Syrup::Institutions::ZionsBank
Instance Attribute Summary
#password, #secret_questions, #username
Class Method Summary
collapse
Instance Method Summary
collapse
#accounts, #find_account_by_id, inherited, #initialize, #populate_account, #populate_accounts, #populated=, #populated?, #setup, subclasses
Class Method Details
.id ⇒ Object
12
13
14
|
# File 'lib/syrup/institutions/zions_bank.rb', line 12
def id
"zions_bank"
end
|
.name ⇒ Object
8
9
10
|
# File 'lib/syrup/institutions/zions_bank.rb', line 8
def name
"Zions Bank"
end
|
Instance Method Details
#fetch_account(account_id) ⇒ Object
17
18
19
|
# File 'lib/syrup/institutions/zions_bank.rb', line 17
def fetch_account(account_id)
fetch_accounts
end
|
#fetch_accounts ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/syrup/institutions/zions_bank.rb', line 21
def fetch_accounts
ensure_authenticated
page = agent.get('https://banking.zionsbank.com/ibuir/displayAccountBalance.htm')
json = MultiJson.load(page.body)
accounts = []
json['accountBalance']['depositAccountList'].each do |account|
new_account = Account.new(:id => account['accountId'], :institution => self)
new_account.name = unescape_html(account['name'])
new_account.account_number = account['number']
new_account.current_balance = parse_currency(account['currentAmt'])
new_account.available_balance = parse_currency(account['availableAmt'])
new_account.type = :deposit
accounts << new_account
end
json['accountBalance']['creditAccountList'].each do |account|
new_account = Account.new(:id => account['accountId'], :institution => self)
new_account.name = unescape_html(account['name'])
new_account.account_number = account['number']
new_account.current_balance = parse_currency(account['balanceDueAmt'])
new_account.type = :credit
accounts << new_account
end
accounts
end
|
#fetch_transactions(account_id, starting_at, ending_at) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/syrup/institutions/zions_bank.rb', line 52
def fetch_transactions(account_id, starting_at, ending_at)
ensure_authenticated
transactions = []
post_vars = { "actAcct" => account_id, "dayRange.searchType" => "dates", "dayRange.startDate" => starting_at.strftime('%m/%d/%Y'), "dayRange.endDate" => ending_at.strftime('%m/%d/%Y'), "submit_view.x" => 11, "submit_view.y" => 11, "submit_view" => "view" }
page = agent.post("https://banking.zionsbank.com/zfnb/userServlet/app/bank/user/register_view_main?reSort=false&actAcct=#{account_id}", post_vars)
page.search('tr').each do |row_element|
account = find_account_by_id(account_id)
datapart = row_element.css('.acct')
if datapart && datapart.inner_html.size > 0
if match = /Prior Day Balance:\s*([^<]+)/.match(datapart.inner_html)
account.prior_day_balance = parse_currency(match[1])
end
if match = /Current Balance:\s*([^<]+)/.match(datapart.inner_html)
account.current_balance = parse_currency(match[1])
end
if match = /Available Balance:\s*([^<]+)/.match(datapart.inner_html)
account.available_balance = parse_currency(match[1])
end
end
data = []
datapart = row_element.css('.data')
if datapart
data += datapart
datapart = row_element.css('.curr')
data += datapart if datapart
end
datapart = row_element.css('.datagrey')
if datapart
data += datapart
datapart = row_element.css('.currgrey')
data += datapart if datapart
end
if data.size == 7
data.map! {|cell| cell.inner_html.strip.gsub(/[^ -~]/, '') }
transaction = Transaction.new
transaction.posted_at = Date.strptime(data[0], '%m/%d/%Y')
transaction.payee = unescape_html(data[2])
transaction.status = data[3].include?("Posted") ? :posted : :pending
unless data[4].empty?
transaction.amount = -parse_currency(data[4])
end
unless data[5].empty?
transaction.amount = parse_currency(data[5])
end
transactions << transaction
end
end
transactions
end
|