goodwill 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e719b975ab0646de6f53fe98886aec39e1854ee99801c825d7ac7301ffa13f40
4
- data.tar.gz: 7e9bdce4e2ca7c0e7b621b40226073b11fea1f81e8809b13e62efe33fbee6c97
3
+ metadata.gz: 4067be1f98e0d4de75e6b2880f35d671d8d88b3d939aaa64b1e85c5448775759
4
+ data.tar.gz: e5eedc6e6208cbf1b9706349bf7485934c1b2c4d91f07a8d655775134dcf151c
5
5
  SHA512:
6
- metadata.gz: b6d88107b867793646fccb768784e7831220614e3e2cd4cd25c33a37d7c7032cfa5cc06475c16b37d17351c851be3d4fb86975dd978b88288e32ca038b8c57c3
7
- data.tar.gz: 56684c90f1313a7855054ba342d076d752405d9f387d43de2582b86f5f612e901d46167657d42453a2cf7c354b94e8d4e0817311487e4ef76bcdf33f426ab5b6
6
+ metadata.gz: a5351d1a764cf460f4e0850da86ae0f95da9608ead60742f25e42477d71bfbdf9a8fe2c78e7a28037060088b85c00f66db637dc0fa6ee193a51e7880a9f34dde
7
+ data.tar.gz: d1b3b90c793943446a2e0ac4b676b3785d2e4eb2d85ef997f59dbd8c030c170707b5049c06cc2867ddeb63f19077049c80a3fec22f1aa41f867e5ee2131dac0d
@@ -1,9 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.0
4
- - 2.3.0
5
- - 2.4.0
6
3
  - 2.5.0
4
+ - 2.6.0
5
+ - 2.7.0
7
6
  before_install: gem install bundler
8
7
  script:
9
8
  - bundle exec rspec
@@ -65,13 +65,14 @@ module Goodwill
65
65
  # -5 - bid less than minimum
66
66
  mechanize.get(BID_URL, params) do |page|
67
67
  res = JSON.parse(page.body)
68
- if res['BidResult'] == 1
68
+ case res['BidResult']
69
+ when 1
69
70
  return true if res['BidResultMessage'].include?('Bid Received')
70
71
 
71
72
  return false if res['BidResultMessage'].include?('You have already been outbid.')
72
73
 
73
74
  raise Goodwill::BidError, res['BidResultMessage']
74
- elsif res['BidResult'] == -5
75
+ when -5
75
76
  raise Goodwill::BidError, res['BidResultMessage']
76
77
  end
77
78
  end
@@ -15,17 +15,7 @@ module Goodwill
15
15
  include CSSPaths
16
16
  include URLPaths
17
17
 
18
- attr_reader :item_page
19
-
20
- attr_reader :bids
21
- attr_reader :current
22
- attr_reader :end
23
- attr_reader :href
24
- attr_reader :item
25
- attr_reader :itemid
26
- attr_reader :seller
27
- attr_reader :shipping
28
- attr_reader :type
18
+ attr_reader :item_page, :bids, :current, :end, :href, :item, :itemid, :seller, :shipping, :type
29
19
 
30
20
  def initialize(itemid, zipcode = '97222', state = 'OR', country = 'US')
31
21
  @itemid = itemid
@@ -70,6 +60,9 @@ module Goodwill
70
60
  params = "?ZipCode=#{zipcode}&Country=#{country}&ItemId=#{itemid}&Quantity=1&_=#{DateTime.now.strftime('%s')}"
71
61
  page = mechanize.get(SHIPPING_URL + params)
72
62
  page.search(SHIPPING_PATH).text.split(': ').last.tr('$', '').to_f
63
+ rescue StandardError
64
+ puts "Timeout (#{e}), retrying in 1 second..."
65
+ retry
73
66
  end
74
67
 
75
68
  def parse_end_time
@@ -6,19 +6,10 @@ module Goodwill
6
6
  class BiddingAuction < Auction
7
7
  include URLPaths
8
8
 
9
- attr_reader :bidding
10
- attr_reader :winning
11
- attr_reader :max
9
+ attr_reader :bidding, :winning, :max, :current, :end, :href, :item, :itemid, :seller, :shipping
12
10
 
13
11
  # TODO: why do i need this?
14
12
  attr_reader :bids
15
- attr_reader :current
16
- attr_reader :end
17
- attr_reader :href
18
- attr_reader :item
19
- attr_reader :itemid
20
- attr_reader :seller
21
- attr_reader :shipping
22
13
 
23
14
  def initialize(itemid, mechanize)
24
15
  super(itemid)
@@ -7,6 +7,7 @@ module Goodwill
7
7
  class_option :verbose, type: :boolean
8
8
  class_option :username
9
9
  class_option :password
10
+ class_option :threads
10
11
 
11
12
  def initialize(*args)
12
13
  super
@@ -14,7 +15,8 @@ module Goodwill
14
15
 
15
16
  username = options[:username] || ask('Username:')
16
17
  password = options[:password] || ask('Password:') { |q| q.echo = false }
17
- @account = Goodwill::Account.new(username, password)
18
+ threads = options[:threads].to_i || 10
19
+ @account = Goodwill::Account.new(username, password, threads)
18
20
  end
19
21
 
20
22
  desc 'auctions', "List all auctions you're currently bidding on"
@@ -17,14 +17,12 @@ module Goodwill
17
17
  @username ||= nil
18
18
  end
19
19
 
20
- attr_writer :username
20
+ attr_writer :username, :password
21
21
 
22
22
  def password
23
23
  @password ||= nil
24
24
  end
25
25
 
26
- attr_writer :password
27
-
28
26
  def logged_in?
29
27
  @logged_in ||= false
30
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Goodwill
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goodwill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Burnett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2020-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem-release