Class: FineAnts::Adapters::Betterment

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

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Betterment

Returns a new instance of Betterment.



6
7
8
9
# File 'lib/fine_ants/adapters/betterment.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
48
49
# File 'lib/fine_ants/adapters/betterment.rb', line 32

def download
  all(".ft-goalAccordionLabel").each do |accordion|
    accordion.click
    sleep 0.3
  end
  accounts = all ".ft-goalExpandedFooter .sc-ContentLayout:nth-child(1) .ft-accounts .ft-subAccountExpandedRow"
  accounts.map { ||
    {
      adapter: :betterment,
      user: @user,
      id: id_for(),
      name: name_for(),
      amount: total_for()
    }
  }.tap do
    find_logout_button.click
  end
end

#loginObject



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

def 
  visit "https://wwws.betterment.com/app/login"
  fill_in "web_authentication[email]", with: @user
  fill_in "web_authentication[password]", with: @password
  click_button "Log in"
  begin
    find_field "web_second_factor_authentication[verification_code]"
    false
  rescue Capybara::ElementNotFound
    verify_login!
    true
  end
end

#two_factor_response(answer) ⇒ Object



25
26
27
28
29
30
# File 'lib/fine_ants/adapters/betterment.rb', line 25

def two_factor_response(answer)
  fill_in "web_second_factor_authentication[verification_code]", with: answer
  find(".web_second_factor_authentication_trust_device").click
  click_button "Verify"
  verify_login!
end