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
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fine_ants/adapters/amex.rb', line 21 def download visit "https://global.americanexpress.com/accounts" all(".card-block > div").map do |account| name = account.find('.heading-3').text owed = account.all("table td").size == 3 { :adapter => :amex, :user => @user, :id => name, :name => name, :amount => -1 * BigDecimal.new(if owed account.find("table td:nth-child(2) span").text.gsub(/[\$,]/,'') else "0" end) } end.tap do page.driver.go_back "Log Out" end end |
#login ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/fine_ants/adapters/amex.rb', line 11 def login visit "https://www.americanexpress.com" within "#ssoform" do fill_in "User ID", :with => @user fill_in "Password", :with => @password click_link "Log In" end verify_login! end |