Class: FineAnts::Adapters::Etrade

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

Instance Method Summary collapse

Constructor Details

#initialize(credentials) ⇒ Etrade

Returns a new instance of Etrade.



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

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

Instance Method Details

#downloadObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fine_ants/adapters/etrade.rb', line 20

def download
  all("section.account").map { ||
    {
      adapter: :etrade,
      user: @user,
      id: .find("#acctNum .number-reveal", visible: false).text(:all),
      name: .find("a.account-id").text,
      amount: BigDecimal(.find(".table-horizontal .text-right.secondary").text.gsub(/[\$,]/, ""))
    }
  }.tap do
    click_link "Log Off"
  end
end

#loginObject



11
12
13
14
15
16
17
18
# File 'lib/fine_ants/adapters/etrade.rb', line 11

def 
  visit "https://us.etrade.com/e/t/user/login"
  fill_in "USER", with: @user
  sleep 0.3
  fill_in "PASSWORD", with: @password
  click_button "Log on"
  verify_login!
end