Class: FineAnts::Adapters::Vanguard
- Inherits:
-
Object
- Object
- FineAnts::Adapters::Vanguard
- Defined in:
- lib/fine_ants/adapters/vanguard.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(credentials) ⇒ Vanguard
constructor
A new instance of Vanguard.
- #login ⇒ Object
- #two_factor_response(answer) ⇒ Object
Constructor Details
#initialize(credentials) ⇒ Vanguard
Returns a new instance of Vanguard.
6 7 8 9 |
# File 'lib/fine_ants/adapters/vanguard.rb', line 6 def initialize(credentials) @user = credentials[:user] @password = credentials[:password] end |
Instance Method Details
#download ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fine_ants/adapters/vanguard.rb', line 33 def download rows = find("[id='BalancesTabBoxId:balancesForm:balancesTable']").all("tr:not([tbodyid])") rows.map { |row| cells = row.all("td") { adapter: :vanguard, user: @user, id: cells.first.all("a").first[:href].match(/.*#(.*)$/)[1], name: cells.first.text, amount: BigDecimal(cells.last.text.match(/\$(.*)$/)[1].delete(",")) } }.tap { click_link "Log off" } end |
#login ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fine_ants/adapters/vanguard.rb', line 11 def login visit "https://personal.vanguard.com/us/hnwnesc/nesc/LoginPage" fill_in "LoginForm:USER", with: @user sleep 0.2 fill_in "LoginForm:PASSWORD-blocked", with: @password "LoginForm:submitInput" begin find_field "LoginForm:ANSWER" false rescue Capybara::ElementNotFound verify_login! true end end |
#two_factor_response(answer) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fine_ants/adapters/vanguard.rb', line 26 def two_factor_response(answer) fill_in "LoginForm:ANSWER", with: answer choose "LoginForm:DEVICE:0" "LoginForm:ContinueInput" verify_login! end |