Module: Goodwill::Mechanize

Extended by:
URLPaths
Included in:
Account, Auction
Defined in:
lib/goodwill/mechanize.rb

Constant Summary

Constants included from URLPaths

URLPaths::BID_URL, URLPaths::ITEM_SEARCH_URL, URLPaths::LOGIN_URL, URLPaths::OPEN_ORDERS_URL, URLPaths::SEARCH_URL, URLPaths::SHIPPING_URL

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.passwordObject



22
23
24
# File 'lib/goodwill/mechanize.rb', line 22

def password
  @password ||= nil
end

.usernameObject



16
17
18
# File 'lib/goodwill/mechanize.rb', line 16

def username
  @username ||= nil
end

Class Method Details

.logged_in?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/goodwill/mechanize.rb', line 26

def logged_in?
  @logged_in ||= false
end

.loginObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/goodwill/mechanize.rb', line 36

def 
  return true if logged_in?

  @mechanize.get(LOGIN_URL) do |page|
    my_page = page.form_with(action: '/SignIn') do |f|
      f.Username = @username
      f.Password = @password
    end.click_button
    @logged_in = my_page.links.map(&:to_s).include? 'My Shopgoodwill '
  end
end

.mechanizeObject



30
31
32
33
34
# File 'lib/goodwill/mechanize.rb', line 30

def mechanize
  @mechanize ||= ::Mechanize.new
  
  @mechanize
end

Instance Method Details

#mechanizeObject



9
10
11
# File 'lib/goodwill/mechanize.rb', line 9

def mechanize
  Mechanize.mechanize
end