Module: Goodwill::Mechanize
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
permalink
.password ⇒ Object
21
22
23
|
# File 'lib/goodwill/mechanize.rb', line 21
def password
@password ||= nil
end
|
permalink
.username ⇒ Object
15
16
17
|
# File 'lib/goodwill/mechanize.rb', line 15
def username
@username ||= nil
end
|
Class Method Details
permalink
.logged_in? ⇒ Boolean
[View source]
27
28
29
|
# File 'lib/goodwill/mechanize.rb', line 27
def logged_in?
@logged_in ||= false
end
|
[View source]
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/goodwill/mechanize.rb', line 37
def login
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
|
permalink
.mechanize ⇒ Object
[View source]
31
32
33
34
35
|
# File 'lib/goodwill/mechanize.rb', line 31
def mechanize
@mechanize ||= ::Mechanize.new
login
@mechanize
end
|