Class: FineAnts::Adapters::Simple

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

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Simple

Returns a new instance of Simple.



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

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

Instance Method Details

#downloadObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fine_ants/adapters/simple.rb', line 32

def download
  user_name = find(".masthead-username").text
  balance = find_all(".balances-item-value").first.text
  available_balance = find(".balances-sts .amount").text.strip

  [
    {
      adapter: :simple,
      user: @user,
      id: user_name.to_s,
      name: user_name.to_s,
      amount: parse_currency(balance),
      available_amount: parse_currency(available_balance)
    }
  ].tap { logout! }
end

#loginObject



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

def 
  visit "https://www.simple.com"
  click_link "Log In"

  fill_in "login_username", with: @user
  fill_in "login_password", with: @password
  click_button "Sign In"
  begin
    find_field "Enter 4-digit code"
    false
  rescue Capybara::ElementNotFound
    verify_login!
    true
  end
end

#two_factor_response(answer) ⇒ Object



27
28
29
30
# File 'lib/fine_ants/adapters/simple.rb', line 27

def two_factor_response(answer)
  fill_in "Enter 4-digit code", with: answer
  click_button "Verify"
end