Class: FineAnts::Adapters::Pnc

Inherits:
Object
  • Object
show all
Defined in:
lib/fine_ants/adapters/pnc.rb

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Pnc

Returns a new instance of Pnc.



6
7
8
9
# File 'lib/fine_ants/adapters/pnc.rb', line 6

def initialize(credentials)
  @user = credentials[:user]
  @password = credentials[:password]
end

Instance Method Details

#downloadObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fine_ants/adapters/pnc.rb', line 38

def download
  rows = all("#depositAccountsWrapper tr.depAccount")
  rows.map do |row|
    cells = row.all("td")
    {
      :adapter => :pnc,
      :user => @user,
      :id => cells[2].text, # TODO - this won't be unique, only gives last 4 :-/
      :name => cells[0].text,
      :amount => BigDecimal.new(cells[3].text.match(/\$(.*)$/)[1].gsub(/,/,''))
    }
  end.tap { click_link "Sign Off" }
end

#loginObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fine_ants/adapters/pnc.rb', line 11

def 
  visit "https://www.onlinebanking.pnc.com/alservlet/SignonInitServlet"
  fill_in "userId", :with => @user
  fill_in "password", :with => @password
  click_button "Sign On"

  if all("input[value='Generate Code']").any?
    click_button "Generate Code"
    return false
  elsif all("input[name=answer]").any?
    return false
  else
    verify_login!
    return true
  end
end

#two_factor_response(text_or_answer) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/fine_ants/adapters/pnc.rb', line 28

def two_factor_response(text_or_answer)
  if all("input[name=answer]").any? # Security Q
    fill_in "answer", :with => text_or_answer
  else # Text message challenge
    fill_in "otpNumber", :with => text_or_answer
  end
  click_button "Continue"
  verify_login!
end