Class: FineAnts::Adapters::Amex
- Inherits:
-
Object
- Object
- FineAnts::Adapters::Amex
- Defined in:
- lib/fine_ants/adapters/amex.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(credentials) ⇒ Amex
constructor
A new instance of Amex.
- #login ⇒ Object
Constructor Details
#initialize(credentials) ⇒ Amex
Returns a new instance of Amex.
6 7 8 9 |
# File 'lib/fine_ants/adapters/amex.rb', line 6 def initialize(credentials) @user = credentials[:user] @password = credentials[:password] end |
Instance Method Details
#download ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fine_ants/adapters/amex.rb', line 22 def download visit "https://global.americanexpress.com/accounts" find(".card-block") all(".card-block > div").map do |account| name = account.find(".card > .pad > .heading-3").text owed = account.text.include?("Total Balance") { adapter: :amex, user: @user, id: name, name: name, amount: -1 * BigDecimal(if owed account.all("table td:nth-child(2) span").first.text.gsub(/[\$,]/, "") else "0" end) } end end |
#login ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fine_ants/adapters/amex.rb', line 11 def login visit "https://www.americanexpress.com" form_css = find("form")[:id] == "ssoform" ? "#ssoform" : ".eliloMain" within form_css do fill_in "User ID", with: @user fill_in "Password", with: @password click_thing "Log In" end verify_login! end |