Module: Goodwill::Mechanize

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

Constant Summary

Constants included from URLPaths

URLPaths::ITEM_SEARCH_URL, URLPaths::LOGIN_URL, URLPaths::OPEN_ORDERS_URL, URLPaths::SEARCH_URL

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.passwordObject


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

def password
  @password ||= nil
end

.usernameObject


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

def username
  @username ||= nil
end

Class Method Details

.logged_in?Boolean

Returns:

  • (Boolean)
[View source]

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

def logged_in?
  @logged_in ||= false
end

.loginObject

[View source]

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

def 
  return true if logged_in?
  @mechanize.get(LOGIN_URL) do |page|
    my_page = page.form_with(action: 'dologin.asp') do |f|
      f.buyerid     = @username
      f.buyerpasswd = @password
    end.click_button
    @logged_in = my_page.links.map(&:to_s).include? 'My shopgoodwill'
  end
end

.mechanizeObject

[View source]

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

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

Instance Method Details

#mechanizeObject

[View source]

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

def mechanize
  Mechanize.mechanize
end