Class: FineAnts::Adapters::Schwab
- Inherits:
-
Object
- Object
- FineAnts::Adapters::Schwab
- Defined in:
- lib/fine_ants/adapters/schwab.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(credentials) ⇒ Schwab
constructor
A new instance of Schwab.
- #login ⇒ Object
- #two_factor_response(answer) ⇒ Object
Constructor Details
#initialize(credentials) ⇒ Schwab
Returns a new instance of Schwab.
6 7 8 9 |
# File 'lib/fine_ants/adapters/schwab.rb', line 6 def initialize(credentials) @user = credentials[:user] @password = credentials[:password] end |
Instance Method Details
#download ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fine_ants/adapters/schwab.rb', line 35 def download rows = all(".account-row") rows.map { |row| { adapter: :schwab, user: @user, id: row.all(".account.number").first.text.strip, name: row.all(".nickName-wrapper").first.text.strip, amount: BigDecimal(row.all(".balance-container-cs .values-wrapper").first.text.match(/\$(.*)$/)[1].delete(",")) } }.tap { "Log Out" } end |
#login ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fine_ants/adapters/schwab.rb', line 11 def login visit "https://client.schwab.com/Login/SignOn/CustomerCenterLogin.aspx" within_frame 'lmsSecondaryLogin' do fill_in "loginIdInput", with: @user fill_in "passwordInput", with: @password select "Accounts Summary", from: "landingPageOptions" "btnLogin" end begin find("#otp_sms").click false rescue Capybara::ElementNotFound verify_login! true end end |
#two_factor_response(answer) ⇒ Object
29 30 31 32 33 |
# File 'lib/fine_ants/adapters/schwab.rb', line 29 def two_factor_response(answer) fill_in "securityCode", with: answer "continueButton" verify_login! end |