goodwill 0.3.0 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.rubocop.yml +10 -4
- data/.ruby-version +1 -0
- data/.travis.yml +3 -3
- data/Gemfile +5 -0
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/bin/goodwill +2 -0
- data/goodwill.gemspec +16 -21
- data/lib/goodwill.rb +6 -1
- data/lib/goodwill/account.rb +55 -23
- data/lib/goodwill/auction.rb +36 -20
- data/lib/goodwill/biddingauction.rb +5 -15
- data/lib/goodwill/cli.rb +17 -3
- data/lib/goodwill/csspaths.rb +15 -6
- data/lib/goodwill/logger.rb +2 -0
- data/lib/goodwill/mechanize.rb +8 -7
- data/lib/goodwill/urlpaths.rb +8 -5
- data/lib/goodwill/version.rb +3 -1
- metadata +91 -64
- data/Gemfile.old +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YWZlOTA3NDljN2ZmM2I3Y2Q2NzJiZWRhNzBjYjUyZmVlZGQ1MGJhNQ==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4179a1b7a46965ea77ed93238d5627d89e7bc1463c7c5a2aef0be750cab52d6e
|
4
|
+
data.tar.gz: 353fe9f4c623e93ea19554591840733a2436c9a1e2bd07a86da104b4f0b0029e
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OGJiYzA4M2UxODNkODQ0YzFmN2RhMTVmZWMwOTg2MmMwY2Q3MDIxYjA0ZWRk
|
11
|
-
MzE5YzVlYWZiZDZhOTQ4MmZiNjE2YjdjYTViMjE4NTJjMDVjN2U=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MGUxNmVmMTFmY2M5NjhjOGM1NTI5MWZkNmIxZjI2YWY1YzdhMTFkMGEwMmFk
|
14
|
-
MWU2ZmFkOTkyMDMwNTUzZTNhMWNjMGVjZTU2YTA0MjAwNGVlMWZmODQzOTY3
|
15
|
-
YzBmNmY2ZGUzNDViMWQxNjMxNGNlNzA4YTVkNDQ0Njk3ODZiNWQ=
|
6
|
+
metadata.gz: c634d19b4480caa3b7d1b54680b16078cfb5c182dd8ed1aac7367b3681c0593ad87fe0c45589ded56e71cfe7561371f124a43b9fbaec3fb007bb9df8c9ad86de
|
7
|
+
data.tar.gz: 204669e69d251295d875a94ebb4f0f760afd2017945d1be77a5333309811923c0f21fd53a1ee885088ab10903a946564e187c1755f81d965dcde2451d937ca2f
|
data/.rubocop.yml
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
|
4
|
+
Layout/LineLength:
|
5
|
+
Max: 150
|
3
6
|
|
4
7
|
Metrics/AbcSize:
|
5
|
-
|
8
|
+
Max: 30
|
6
9
|
|
7
|
-
Metrics/
|
10
|
+
Metrics/BlockLength:
|
8
11
|
Max: 200
|
9
12
|
|
10
13
|
Metrics/MethodLength:
|
11
14
|
Max: 20
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/.travis.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
before_install: gem install bundler
|
3
|
+
- 2.6.0
|
4
|
+
before_install: gem install bundler
|
5
5
|
script:
|
6
6
|
- bundle exec rspec
|
7
|
-
- bundle exec rubocop
|
7
|
+
- bundle exec rubocop ./lib
|
8
8
|
deploy:
|
9
9
|
provider: rubygems
|
10
10
|
api_key:
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/bin/goodwill
CHANGED
data/goodwill.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'goodwill/version'
|
5
6
|
|
@@ -14,29 +15,23 @@ Gem::Specification.new do |spec|
|
|
14
15
|
spec.description = 'Allows you to perform basic auction management, bidding, and searching from ruby.'
|
15
16
|
spec.homepage = 'https://github.com/dudemcbacon/goodwill'
|
16
17
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
-
# delete this section to allow pushing this gem to any host.
|
19
|
-
if spec.respond_to?(:metadata)
|
20
|
-
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
|
-
else
|
22
|
-
fail 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
23
|
-
end
|
24
|
-
|
25
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
19
|
spec.bindir = 'exe'
|
27
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
21
|
spec.require_paths = ['lib']
|
29
22
|
|
23
|
+
spec.add_development_dependency 'gem-release'
|
24
|
+
spec.add_development_dependency 'pry'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
30
28
|
spec.add_development_dependency 'simplecov'
|
31
|
-
spec.add_development_dependency '
|
32
|
-
spec.add_development_dependency '
|
33
|
-
spec.add_development_dependency '
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.add_dependency '
|
38
|
-
spec.add_dependency '
|
39
|
-
spec.add_dependency 'mechanize', '~> 2.7'
|
40
|
-
spec.add_dependency 'table_print', '~> 1.5'
|
41
|
-
spec.add_dependency 'thor', '~> 0.19'
|
29
|
+
spec.add_development_dependency 'travis'
|
30
|
+
spec.add_development_dependency 'vcr'
|
31
|
+
spec.add_development_dependency 'webmock'
|
32
|
+
spec.add_dependency 'highline'
|
33
|
+
spec.add_dependency 'mechanize'
|
34
|
+
spec.add_dependency 'parallel'
|
35
|
+
spec.add_dependency 'table_print'
|
36
|
+
spec.add_dependency 'thor'
|
42
37
|
end
|
data/lib/goodwill.rb
CHANGED
data/lib/goodwill/account.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'goodwill/auction'
|
2
4
|
require 'goodwill/mechanize'
|
3
5
|
require 'goodwill/urlpaths'
|
6
|
+
require 'goodwill/csspaths'
|
4
7
|
|
8
|
+
require 'json'
|
5
9
|
require 'mechanize'
|
6
10
|
require 'parallel'
|
7
11
|
|
@@ -12,8 +16,8 @@ module Goodwill
|
|
12
16
|
class Account
|
13
17
|
include Goodwill::Mechanize
|
14
18
|
include URLPaths
|
19
|
+
include CSSPaths
|
15
20
|
|
16
|
-
IN_PROG = 'https://www.shopgoodwill.com/buyers/myShop/AuctionsInProgress.asp'
|
17
21
|
PER_PAGE = 25
|
18
22
|
|
19
23
|
attr_reader :username, :password, :threads
|
@@ -27,51 +31,79 @@ module Goodwill
|
|
27
31
|
end
|
28
32
|
|
29
33
|
def in_progress
|
30
|
-
in_progress_page = mechanize.get(
|
31
|
-
Parallel.map(in_progress_page.search(
|
34
|
+
in_progress_page = mechanize.get(OPEN_ORDERS_URL)
|
35
|
+
Parallel.map(in_progress_page.search(IN_PROGRESS_ROWS), in_threads: @threads) do |row|
|
32
36
|
Goodwill::BiddingAuction.new(itemid_from_open_order_row(row), mechanize)
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
40
|
def search(item_title)
|
37
41
|
search_page = mechanize.get(SEARCH_URL + item_title)
|
38
|
-
pages(total_items(search_page))
|
39
|
-
search_page = search_page.link_with(text: '
|
40
|
-
Parallel.map(search_page.search(
|
42
|
+
Array.new(pages(total_items(search_page))) do |i|
|
43
|
+
search_page = search_page.link_with(text: '>').click unless i.zero?
|
44
|
+
Parallel.map(search_page.search(SEARCH_ROWS), in_threads: @threads) do |row|
|
41
45
|
Goodwill::Auction.new(itemid_from_search_row(row))
|
42
46
|
end
|
43
47
|
end.flatten
|
44
48
|
end
|
45
49
|
|
46
50
|
def bid(itemid, bid)
|
47
|
-
mechanize.get(ITEM_SEARCH_URL + itemid.to_s)
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
item = mechanize.get(ITEM_SEARCH_URL + itemid.to_s)
|
52
|
+
href = item.search(SELLER_ID_LINK).attribute('href').value
|
53
|
+
seller_id = href.split('/').last
|
54
|
+
|
55
|
+
params = {
|
56
|
+
itemId: itemid,
|
57
|
+
bidAmount: bid,
|
58
|
+
quantity: 1,
|
59
|
+
sellerId: seller_id
|
60
|
+
}
|
61
|
+
|
62
|
+
# bidresult
|
63
|
+
# 1 - success (check message for 'Bid Received!')
|
64
|
+
# 1 - outbid (check message for 'You have already been outbid.')
|
65
|
+
# -5 - bid less than minimum
|
66
|
+
mechanize.get(BID_URL, params) do |page|
|
67
|
+
res = JSON.parse(page.body)
|
68
|
+
case res['BidResult']
|
69
|
+
when 1
|
70
|
+
return true if res['BidResultMessage'].include?('Bid Received')
|
71
|
+
|
72
|
+
return false if res['BidResultMessage'].include?('You have already been outbid.')
|
73
|
+
|
74
|
+
raise Goodwill::BidError, res['BidResultMessage']
|
75
|
+
when -5
|
76
|
+
raise Goodwill::BidError, res['BidResultMessage']
|
77
|
+
end
|
56
78
|
end
|
57
79
|
end
|
58
80
|
|
59
81
|
private
|
60
82
|
|
61
|
-
def
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
def total_items(page)
|
66
|
-
page.search('div h1').text.split.first.to_i
|
83
|
+
def buyer_token
|
84
|
+
mechanize.cookies.select { |c| c.name == 'AuthenticatedBuyerToken' }.first.value
|
67
85
|
end
|
68
86
|
|
69
87
|
def itemid_from_open_order_row(row)
|
70
|
-
row.search('a').
|
88
|
+
row.search('a').text
|
71
89
|
end
|
72
90
|
|
73
91
|
def itemid_from_search_row(row)
|
74
|
-
row.search('
|
92
|
+
row.search('a').first.attributes['href'].value.split('/').last
|
93
|
+
end
|
94
|
+
|
95
|
+
def pages(items)
|
96
|
+
(items / 40.to_f).ceil
|
97
|
+
end
|
98
|
+
|
99
|
+
def request_token
|
100
|
+
mechanize.cookies.select { |c| c.name == '__RequestVerificationToken' }.first.value
|
101
|
+
end
|
102
|
+
|
103
|
+
def total_items(page)
|
104
|
+
return 0 unless page.search(NO_ITEMS_FOUND_PATH).empty?
|
105
|
+
|
106
|
+
page.search(ITEMS_COUNT_PATH).first.text.split(' of ')[1].split(' ').first.to_i
|
75
107
|
end
|
76
108
|
end
|
77
109
|
end
|
data/lib/goodwill/auction.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mechanize'
|
2
4
|
|
3
5
|
require 'goodwill/csspaths'
|
@@ -13,30 +15,25 @@ module Goodwill
|
|
13
15
|
include CSSPaths
|
14
16
|
include URLPaths
|
15
17
|
|
16
|
-
attr_reader :bids
|
17
|
-
attr_reader :current
|
18
|
-
attr_reader :end
|
19
|
-
attr_reader :href
|
20
|
-
attr_reader :item
|
21
|
-
attr_reader :itemid
|
22
|
-
attr_reader :seller
|
23
|
-
attr_reader :shipping
|
18
|
+
attr_reader :item_page, :bids, :current, :end, :href, :item, :itemid, :seller, :shipping, :type
|
24
19
|
|
25
|
-
def initialize(itemid, zipcode = '97222', state = 'OR', country = '
|
20
|
+
def initialize(itemid, zipcode = '97222', state = 'OR', country = 'US')
|
26
21
|
@itemid = itemid
|
27
22
|
@zipcode = zipcode
|
28
23
|
@state = state
|
29
24
|
@country = country
|
30
25
|
|
31
26
|
@href = ITEM_SEARCH_URL + itemid.to_s
|
32
|
-
item_page = mechanize.get(@href)
|
27
|
+
@item_page = mechanize.get(@href)
|
28
|
+
|
29
|
+
@type = parse_type
|
33
30
|
@bids = item_page.search(BIDS_PATH).text[/\d+/].to_i
|
34
31
|
@current = item_page.search(CURRENT_PRICE_PATH).text.tr('$', '').to_f
|
35
|
-
@end =
|
32
|
+
@end = parse_end_time
|
36
33
|
@item = item_page.search(ITEM_TITLE_PATH).text
|
37
34
|
@seller = item_page.search(SELLER_PATH).text
|
38
35
|
@bidding = false
|
39
|
-
@shipping = calculate_shipping(@itemid, @zipcode, @
|
36
|
+
@shipping = calculate_shipping(@itemid, @zipcode, @country)
|
40
37
|
end
|
41
38
|
|
42
39
|
def ==(other)
|
@@ -46,21 +43,40 @@ module Goodwill
|
|
46
43
|
def to_hash
|
47
44
|
hash = {}
|
48
45
|
instance_variables.each do |var|
|
49
|
-
if var == :@
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
46
|
+
next if var == :@item_page
|
47
|
+
|
48
|
+
hash[var.to_s.delete('@')] = if var == :@end
|
49
|
+
instance_variable_get(var).to_s
|
50
|
+
else
|
51
|
+
instance_variable_get(var)
|
52
|
+
end
|
54
53
|
end
|
55
54
|
hash
|
56
55
|
end
|
57
56
|
|
58
57
|
private
|
59
58
|
|
60
|
-
def calculate_shipping(itemid, zipcode,
|
61
|
-
params = "?
|
59
|
+
def calculate_shipping(itemid, zipcode, country)
|
60
|
+
params = "?ZipCode=#{zipcode}&Country=#{country}&ItemId=#{itemid}&Quantity=1&_=#{DateTime.now.strftime('%s')}"
|
62
61
|
page = mechanize.get(SHIPPING_URL + params)
|
63
|
-
page.search(SHIPPING_PATH).text.tr('$', '').to_f
|
62
|
+
page.search(SHIPPING_PATH).text.split(': ').last.tr('$', '').to_f
|
63
|
+
rescue StandardError
|
64
|
+
puts "Timeout (#{e}), retrying in 1 second..."
|
65
|
+
retry
|
66
|
+
end
|
67
|
+
|
68
|
+
def parse_end_time
|
69
|
+
search_path = type == :auction ? END_TIME_PATH : BIN_END_TIME_PATH
|
70
|
+
time = item_page.search(search_path).text.split(': ')[1]
|
71
|
+
return nil if time.nil?
|
72
|
+
|
73
|
+
DateTime.strptime(time, '%m/%d/%Y %l:%M:%S %p %Z')
|
74
|
+
rescue Date::Error
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_type
|
79
|
+
item_page.search(BUY_IT_NOW_PATH).empty? ? :auction : :buyitnow
|
64
80
|
end
|
65
81
|
end
|
66
82
|
end
|
@@ -1,21 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'goodwill/urlpaths'
|
2
4
|
|
3
5
|
module Goodwill
|
4
6
|
class BiddingAuction < Auction
|
5
7
|
include URLPaths
|
6
8
|
|
7
|
-
attr_reader :bidding
|
8
|
-
attr_reader :winning
|
9
|
-
attr_reader :max
|
9
|
+
attr_reader :bidding, :winning, :max, :current, :end, :href, :item, :itemid, :seller, :shipping
|
10
10
|
|
11
11
|
# TODO: why do i need this?
|
12
12
|
attr_reader :bids
|
13
|
-
attr_reader :current
|
14
|
-
attr_reader :end
|
15
|
-
attr_reader :href
|
16
|
-
attr_reader :item
|
17
|
-
attr_reader :itemid
|
18
|
-
attr_reader :seller
|
19
13
|
|
20
14
|
def initialize(itemid, mechanize)
|
21
15
|
super(itemid)
|
@@ -23,8 +17,8 @@ module Goodwill
|
|
23
17
|
if order_page.link_with(text: regqt(itemid.to_s))
|
24
18
|
@bidding = true
|
25
19
|
row = order_page.link_with(text: regqt(itemid.to_s)).node.parent.parent
|
26
|
-
@winning =
|
27
|
-
@max = row.search('td:nth-child(5)').text
|
20
|
+
@winning = !row.search('td:nth-child(5) > i').empty?
|
21
|
+
@max = row.search('td:nth-child(5)').text.tr("\r\n", '').tr(' ', '').tr('$', '')
|
28
22
|
else
|
29
23
|
@bidding = false
|
30
24
|
@winning = false
|
@@ -37,9 +31,5 @@ module Goodwill
|
|
37
31
|
def regqt(itemid)
|
38
32
|
/#{Regexp.quote(itemid.to_s)}/
|
39
33
|
end
|
40
|
-
|
41
|
-
def happy?(src)
|
42
|
-
src.include?('happy')
|
43
|
-
end
|
44
34
|
end
|
45
35
|
end
|
data/lib/goodwill/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'thor'
|
2
4
|
|
3
5
|
module Goodwill
|
@@ -5,6 +7,7 @@ module Goodwill
|
|
5
7
|
class_option :verbose, type: :boolean
|
6
8
|
class_option :username
|
7
9
|
class_option :password
|
10
|
+
class_option :threads
|
8
11
|
|
9
12
|
def initialize(*args)
|
10
13
|
super
|
@@ -12,19 +15,30 @@ module Goodwill
|
|
12
15
|
|
13
16
|
username = options[:username] || ask('Username:')
|
14
17
|
password = options[:password] || ask('Password:') { |q| q.echo = false }
|
15
|
-
|
18
|
+
threads = options[:threads].to_i || 10
|
19
|
+
@account = Goodwill::Account.new(username, password, threads)
|
16
20
|
end
|
17
21
|
|
18
22
|
desc 'auctions', "List all auctions you're currently bidding on"
|
19
23
|
def auctions
|
20
24
|
say "Your current auctions:\n"
|
21
|
-
|
25
|
+
res = @account.in_progress
|
26
|
+
if res.empty?
|
27
|
+
puts 'No items found.'
|
28
|
+
else
|
29
|
+
tp res
|
30
|
+
end
|
22
31
|
end
|
23
32
|
|
24
33
|
desc 'search SEARCH', 'Search for auctions matching SEARCH'
|
25
34
|
def search(search)
|
26
35
|
say 'Your search results:'
|
27
|
-
|
36
|
+
res = @account.search(search)
|
37
|
+
if res.empty?
|
38
|
+
puts 'No items found.'
|
39
|
+
else
|
40
|
+
tp res
|
41
|
+
end
|
28
42
|
end
|
29
43
|
|
30
44
|
desc 'bid ITEMID MAXBID', 'Bid MAXBID on ITEMID'
|
data/lib/goodwill/csspaths.rb
CHANGED
@@ -1,13 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Goodwill
|
2
4
|
module CSSPaths
|
3
5
|
# Auction Page
|
4
6
|
# http://www.shopgoodwill.com/viewItem.asp?itemID=<itemID>
|
5
|
-
BIDS_PATH = '
|
6
|
-
|
7
|
-
|
7
|
+
BIDS_PATH = 'body > section > div.container > div:nth-child(3) > div:nth-child(2) > ul.product-data > li:nth-child(3) > span.num-bids'
|
8
|
+
BIN_END_TIME_PATH = '/html/body/section/div[2]/div[3]/div[2]/ul[2]/li[7]'
|
9
|
+
BUY_IT_NOW_PATH = '/html/body/section/div[2]/div[3]/div[2]/div[2]/div[1]/div/div/div/button'
|
10
|
+
CURRENT_PRICE_PATH = 'body > section > div.container > div:nth-child(3) > div:nth-child(2) > ul.product-data > li:nth-child(4) > span'
|
11
|
+
END_TIME_PATH = '/html/body/section/div[2]/div[3]/div[2]/ul[2]/li[10]'
|
12
|
+
IN_PROGRESS_ROWS = '#my-auctions-table > tbody > tr'
|
8
13
|
ITEMID_PATH = 'body > span > div.itemdetail > div:nth-child(2) > div:nth-child(2) > div > table > tbody > tr:nth-child(3) > td'
|
9
|
-
|
10
|
-
|
11
|
-
|
14
|
+
ITEMS_COUNT_PATH = '//*[@id="search-results"]/div/div[1]/nav[1]/p'
|
15
|
+
ITEM_TITLE_PATH = 'body > section > div.container > div:nth-child(3) > div:nth-child(2) > h1'
|
16
|
+
NO_ITEMS_FOUND_PATH = '/html/body/section/div[2]/div[4]/div[2]/div/div[2]/p'
|
17
|
+
SEARCH_ROWS = '#search-results > div > section > ul.products > li'
|
18
|
+
SELLER_ID_LINK = '/html/body/section/div[2]/div[4]/div/section/div/ul/li[4]/a'
|
19
|
+
SELLER_PATH = 'body > section > div.container > div:nth-child(3) > div:nth-child(2) > ul.product-data > li:nth-child(8) > a'
|
20
|
+
SHIPPING_PATH = 'body > p:nth-child(7) > b'
|
12
21
|
end
|
13
22
|
end
|
data/lib/goodwill/logger.rb
CHANGED
data/lib/goodwill/mechanize.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'mechanize'
|
2
4
|
|
3
5
|
require 'goodwill/urlpaths'
|
@@ -15,14 +17,12 @@ module Goodwill
|
|
15
17
|
@username ||= nil
|
16
18
|
end
|
17
19
|
|
18
|
-
attr_writer :username
|
20
|
+
attr_writer :username, :password
|
19
21
|
|
20
22
|
def password
|
21
23
|
@password ||= nil
|
22
24
|
end
|
23
25
|
|
24
|
-
attr_writer :password
|
25
|
-
|
26
26
|
def logged_in?
|
27
27
|
@logged_in ||= false
|
28
28
|
end
|
@@ -35,12 +35,13 @@ module Goodwill
|
|
35
35
|
|
36
36
|
def login
|
37
37
|
return true if logged_in?
|
38
|
+
|
38
39
|
@mechanize.get(LOGIN_URL) do |page|
|
39
|
-
my_page = page.form_with(action: '
|
40
|
-
f.
|
41
|
-
f.
|
40
|
+
my_page = page.form_with(action: '/SignIn') do |f|
|
41
|
+
f.Username = @username
|
42
|
+
f.Password = @password
|
42
43
|
end.click_button
|
43
|
-
@logged_in = my_page.links.map(&:to_s).include? 'My
|
44
|
+
@logged_in = my_page.links.map(&:to_s).include? 'My Shopgoodwill '
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
data/lib/goodwill/urlpaths.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Goodwill
|
2
4
|
module URLPaths
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
BID_URL = 'https://www.shopgoodwill.com/Bid/PlaceBid'
|
6
|
+
ITEM_SEARCH_URL = 'https://www.shopgoodwill.com/viewItem.asp?itemID='
|
7
|
+
LOGIN_URL = 'https://www.shopgoodwill.com/SignIn'
|
8
|
+
OPEN_ORDERS_URL = 'https://www.shopgoodwill.com/MyShopgoodwill/AuctionsInProgress'
|
9
|
+
SEARCH_URL = 'https://www.shopgoodwill.com/Listings?sg=&c=&s=&lp=0&hp=999999&sbn=false&spo=false&snpo=false&socs=false&sd=false&sca=false&cadb=7&scs=false&sis=false&col=0&p=1&ps=40&desc=false&ss=0&UseBuyerPrefs=true&st='
|
10
|
+
SHIPPING_URL = 'https://www.shopgoodwill.com/CalculateShipping'
|
8
11
|
end
|
9
12
|
end
|
data/lib/goodwill/version.rb
CHANGED
metadata
CHANGED
@@ -1,183 +1,211 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goodwill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Burnett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: gem-release
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- -
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- -
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- -
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- -
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rubocop
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
75
|
+
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: simplecov
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
89
|
+
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: travis
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
103
|
+
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: vcr
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
117
|
+
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
124
|
+
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: webmock
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
118
|
-
type: :
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: highline
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
|
-
- -
|
143
|
+
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
145
|
+
version: '0'
|
132
146
|
type: :runtime
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
|
-
- -
|
150
|
+
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: mechanize
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- -
|
157
|
+
- - ">="
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
159
|
+
version: '0'
|
146
160
|
type: :runtime
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
|
-
- -
|
164
|
+
- - ">="
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: parallel
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
153
181
|
- !ruby/object:Gem::Dependency
|
154
182
|
name: table_print
|
155
183
|
requirement: !ruby/object:Gem::Requirement
|
156
184
|
requirements:
|
157
|
-
- -
|
185
|
+
- - ">="
|
158
186
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
187
|
+
version: '0'
|
160
188
|
type: :runtime
|
161
189
|
prerelease: false
|
162
190
|
version_requirements: !ruby/object:Gem::Requirement
|
163
191
|
requirements:
|
164
|
-
- -
|
192
|
+
- - ">="
|
165
193
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
194
|
+
version: '0'
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: thor
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
170
198
|
requirements:
|
171
|
-
- -
|
199
|
+
- - ">="
|
172
200
|
- !ruby/object:Gem::Version
|
173
|
-
version: '0
|
201
|
+
version: '0'
|
174
202
|
type: :runtime
|
175
203
|
prerelease: false
|
176
204
|
version_requirements: !ruby/object:Gem::Requirement
|
177
205
|
requirements:
|
178
|
-
- -
|
206
|
+
- - ">="
|
179
207
|
- !ruby/object:Gem::Version
|
180
|
-
version: '0
|
208
|
+
version: '0'
|
181
209
|
description: Allows you to perform basic auction management, bidding, and searching
|
182
210
|
from ruby.
|
183
211
|
email:
|
@@ -186,13 +214,13 @@ executables: []
|
|
186
214
|
extensions: []
|
187
215
|
extra_rdoc_files: []
|
188
216
|
files:
|
189
|
-
- .env
|
190
|
-
- .gitignore
|
191
|
-
- .rspec
|
192
|
-
- .rubocop.yml
|
193
|
-
- .
|
217
|
+
- ".env"
|
218
|
+
- ".gitignore"
|
219
|
+
- ".rspec"
|
220
|
+
- ".rubocop.yml"
|
221
|
+
- ".ruby-version"
|
222
|
+
- ".travis.yml"
|
194
223
|
- Gemfile
|
195
|
-
- Gemfile.old
|
196
224
|
- LICENSE.txt
|
197
225
|
- README.md
|
198
226
|
- Rakefile
|
@@ -213,25 +241,24 @@ files:
|
|
213
241
|
homepage: https://github.com/dudemcbacon/goodwill
|
214
242
|
licenses:
|
215
243
|
- MIT
|
216
|
-
metadata:
|
217
|
-
allowed_push_host: https://rubygems.org
|
244
|
+
metadata: {}
|
218
245
|
post_install_message:
|
219
246
|
rdoc_options: []
|
220
247
|
require_paths:
|
221
248
|
- lib
|
222
249
|
required_ruby_version: !ruby/object:Gem::Requirement
|
223
250
|
requirements:
|
224
|
-
- -
|
251
|
+
- - ">="
|
225
252
|
- !ruby/object:Gem::Version
|
226
253
|
version: '0'
|
227
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
255
|
requirements:
|
229
|
-
- -
|
256
|
+
- - ">="
|
230
257
|
- !ruby/object:Gem::Version
|
231
258
|
version: '0'
|
232
259
|
requirements: []
|
233
260
|
rubyforge_project:
|
234
|
-
rubygems_version: 2.
|
261
|
+
rubygems_version: 2.7.7
|
235
262
|
signing_key:
|
236
263
|
specification_version: 4
|
237
264
|
summary: Basic auction management for ShopGoodwil.com
|