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