Class: FineAnts::Adapters::UfbDirect

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

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ UfbDirect

Returns a new instance of UfbDirect.



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

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

Instance Method Details

#downloadObject



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

def download
  sleep 5
  rows = all(".details-container")
  rows.map { |row|
    {
      adapter: :ufb_direct,
      user: @user,
      id: row.find(".details-container__account-name").text,
      name: row.find(".details-container__account-name").text,
      amount: BigDecimal(
        row.find(".details-container__account-amount").text.match(/\$(.*)$/)[1].delete(",")
      )
    }
  }
end

#loginObject



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

def 
  visit "https://onlinebanking.ufbdirect.com/auth/login"
  sleep 2
  click_link "Login"
  sleep 2
  fill_in "Username", with: @user
  fill_in "Password", with: @password
  sleep 1
  click_button "Login"
  begin
    find ".multi-factor"
    click_button "btn-sms"
    false
  rescue Capybara::ElementNotFound
    verify_login!
    true
  end
end

#two_factor_response(answer) ⇒ Object



30
31
32
33
34
# File 'lib/fine_ants/adapters/ufb_direct.rb', line 30

def two_factor_response(answer)
  fill_in "access-code-entry", with: answer
  click_button "Continue"
  verify_login!
end