gun_broker 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f02df2d0bcc349ad31daf68f74584496eee7b757
4
- data.tar.gz: b5c75e748042ae38d8e3e52b8f254d7cf428c8ba
3
+ metadata.gz: 86f0698b13a91d35ab263f63ee2470539f3dd8b8
4
+ data.tar.gz: 1cc19de5965946075faec30113de9e499fdda037
5
5
  SHA512:
6
- metadata.gz: 28f5d5ee4ddbd7514c088a09bd8ee115329abf79ddc44b70864059b5055dc63e110f360c42e2f3e3354445d4c90b6c0b834742beaf8720044e42254ccbe96b8e
7
- data.tar.gz: 8d442c5f1da97906a72328c95833c39a921861f46e2eddf6a79a815d5d54ac08c1b3c2ced511d00469b7b7c8d6b0610fddef630fe04b53e14a4b4497eeb94f26
6
+ metadata.gz: fafe7b3a6867ea9d3480100dc0e7fb61951908bfb83940bf24fd026b7c23098fdc25eb36c8476b9135152a07f078e0c5b6fe2ff2751619f494cc984e68b2ff32
7
+ data.tar.gz: 1bb0f1bf31616ff94b5cb3a4c3ec1144e44d1e72a99ab0561d7fc0e76e5edcb516b4dff4f493697901f979a1fcf7dabbc94e88fbc4844890287b3d8504c3a472
@@ -12,6 +12,9 @@ module GunBroker
12
12
  # Root URL of the GunBroker sandbox API.
13
13
  ROOT_URL_SANDBOX = 'https://api.sandbox.gunbroker.com/v1'
14
14
 
15
+ # Used to return the maximum number of results from paginated responses.
16
+ PAGE_SIZE = 300
17
+
15
18
  # @param path [String] The requested API endpoint.
16
19
  # @param params [Hash] (optional) URL params for GET requests; form params for POST request.
17
20
  # @param headers [Hash] (optional) Additional headers sent with the request.
@@ -8,7 +8,7 @@ module GunBroker
8
8
  # @param parent_id [Integer, String] (optional) Return all subcategories of the given parent Category ID; defaults to the root (top-level) categories.
9
9
  # @return [Array<Category>] An array of GunBroker::Category instances.
10
10
  def self.all(parent_id = ROOT_CATEGORY_ID)
11
- response = GunBroker::API.get('/Categories', { 'ParentCategoryID' => parent_id })
11
+ response = GunBroker::API.get('/Categories', { 'ParentCategoryID' => parent_id, 'PageSize' => GunBroker::API::PAGE_SIZE })
12
12
  response['results'].map { |attrs| new(attrs) }
13
13
  end
14
14
 
@@ -18,7 +18,10 @@ module GunBroker
18
18
  # @raise [GunBroker::Error::RequestError] If there's an issue with the request (usually a `5xx` response).
19
19
  # @return [Array<Item>]
20
20
  def all
21
- response = GunBroker::API.get('/Items', { 'SellerName' => @user.username }, token_header(@user.token))
21
+ response = GunBroker::API.get('/Items', {
22
+ 'SellerName' => @user.username,
23
+ 'PageSize' => GunBroker::API::PAGE_SIZE
24
+ }, token_header(@user.token))
22
25
  items_from_results(response['results'])
23
26
  end
24
27
 
@@ -27,7 +30,9 @@ module GunBroker
27
30
  # @raise (see #all)
28
31
  # @return [Array<Item>]
29
32
  def bid_on
30
- response = GunBroker::API.get('/ItemsBidOn', {}, token_header(@user.token))
33
+ response = GunBroker::API.get('/ItemsBidOn', {
34
+ 'PageSize' => GunBroker::API::PAGE_SIZE
35
+ }, token_header(@user.token))
31
36
  items_from_results(response['results'])
32
37
  end
33
38
 
@@ -76,7 +81,9 @@ module GunBroker
76
81
  # @raise (see #all)
77
82
  # @return [Array<Item>]
78
83
  def not_won
79
- response = GunBroker::API.get('/ItemsNotWon', {}, token_header(@user.token))
84
+ response = GunBroker::API.get('/ItemsNotWon', {
85
+ 'PageSize' => GunBroker::API::PAGE_SIZE
86
+ }, token_header(@user.token))
80
87
  items_from_results(response['results'])
81
88
  end
82
89
 
@@ -85,7 +92,9 @@ module GunBroker
85
92
  # @raise (see #all)
86
93
  # @return [Array<Item>]
87
94
  def sold
88
- response = GunBroker::API.get('/ItemsSold', {}, token_header(@user.token))
95
+ response = GunBroker::API.get('/ItemsSold', {
96
+ 'PageSize' => GunBroker::API::PAGE_SIZE
97
+ }, token_header(@user.token))
89
98
  items_from_results(response['results'])
90
99
  end
91
100
 
@@ -94,7 +103,9 @@ module GunBroker
94
103
  # @raise (see #all)
95
104
  # @return [Array<Item>]
96
105
  def unsold
97
- response = GunBroker::API.get('/ItemsUnsold', {}, token_header(@user.token))
106
+ response = GunBroker::API.get('/ItemsUnsold', {
107
+ 'PageSize' => GunBroker::API::PAGE_SIZE
108
+ }, token_header(@user.token))
98
109
  items_from_results(response['results'])
99
110
  end
100
111
 
@@ -123,7 +134,9 @@ module GunBroker
123
134
  # @raise (see #all)
124
135
  # @return [Array<Item>]
125
136
  def won
126
- response = GunBroker::API.get('/ItemsWon', {}, token_header(@user.token))
137
+ response = GunBroker::API.get('/ItemsWon', {
138
+ 'PageSize' => GunBroker::API::PAGE_SIZE
139
+ }, token_header(@user.token))
127
140
  items_from_results(response['results'])
128
141
  end
129
142
 
@@ -1,3 +1,3 @@
1
1
  module GunBroker
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.3"
3
3
  end
@@ -35,7 +35,10 @@ describe GunBroker::Category do
35
35
  stub_request(:get, endpoint)
36
36
  .with(
37
37
  headers: headers,
38
- query: { 'ParentCategoryID' => GunBroker::Category::ROOT_CATEGORY_ID }
38
+ query: {
39
+ 'ParentCategoryID' => GunBroker::Category::ROOT_CATEGORY_ID,
40
+ 'PageSize' => GunBroker::API::PAGE_SIZE
41
+ }
39
42
  )
40
43
  .to_return(body: response_fixture('categories'))
41
44
 
@@ -50,7 +53,10 @@ describe GunBroker::Category do
50
53
  stub_request(:get, endpoint)
51
54
  .with(
52
55
  headers: headers,
53
- query: { 'ParentCategoryID' => GunBroker::Category::ROOT_CATEGORY_ID }
56
+ query: {
57
+ 'ParentCategoryID' => GunBroker::Category::ROOT_CATEGORY_ID,
58
+ 'PageSize' => GunBroker::API::PAGE_SIZE
59
+ }
54
60
  )
55
61
  .to_return(body: response_fixture('not_authorized'), status: 401)
56
62
 
@@ -15,7 +15,10 @@ describe GunBroker::User::ItemsDelegate do
15
15
  stub_request(:get, endpoint)
16
16
  .with(
17
17
  headers: headers('X-AccessToken' => token),
18
- query: { 'SellerName' => user.username }
18
+ query: {
19
+ 'SellerName' => user.username,
20
+ 'PageSize' => GunBroker::API::PAGE_SIZE
21
+ }
19
22
  )
20
23
  .to_return(body: response_fixture('items'))
21
24
 
@@ -29,7 +32,10 @@ describe GunBroker::User::ItemsDelegate do
29
32
  stub_request(:get, endpoint)
30
33
  .with(
31
34
  headers: headers('X-AccessToken' => token),
32
- query: { 'SellerName' => user.username }
35
+ query: {
36
+ 'SellerName' => user.username,
37
+ 'PageSize' => GunBroker::API::PAGE_SIZE
38
+ }
33
39
  )
34
40
  .to_return(body: response_fixture('not_authorized'), status: 401)
35
41
 
@@ -44,7 +50,10 @@ describe GunBroker::User::ItemsDelegate do
44
50
  context 'on success' do
45
51
  it 'returns won Items' do
46
52
  stub_request(:get, endpoint)
47
- .with(headers: headers('X-AccessToken' => token))
53
+ .with(
54
+ headers: headers('X-AccessToken' => token),
55
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
56
+ )
48
57
  .to_return(body: response_fixture('items'))
49
58
 
50
59
  user = GunBroker::User.new(username, token: token)
@@ -56,7 +65,10 @@ describe GunBroker::User::ItemsDelegate do
56
65
  context 'on failure' do
57
66
  it 'raises an exception' do
58
67
  stub_request(:get, endpoint)
59
- .with(headers: headers('X-AccessToken' => token))
68
+ .with(
69
+ headers: headers('X-AccessToken' => token),
70
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
71
+ )
60
72
  .to_return(body: response_fixture('not_authorized'), status: 401)
61
73
 
62
74
  user = GunBroker::User.new(username, token: token)
@@ -75,7 +87,10 @@ describe GunBroker::User::ItemsDelegate do
75
87
  stub_request(:get, all_endpoint)
76
88
  .with(
77
89
  headers: headers('X-AccessToken' => token),
78
- query: { 'SellerName' => user.username }
90
+ query: {
91
+ 'SellerName' => user.username,
92
+ 'PageSize' => GunBroker::API::PAGE_SIZE
93
+ }
79
94
  )
80
95
  .to_return(body: response_fixture('items'))
81
96
 
@@ -93,7 +108,10 @@ describe GunBroker::User::ItemsDelegate do
93
108
  stub_request(:get, all_endpoint)
94
109
  .with(
95
110
  headers: headers('X-AccessToken' => token),
96
- query: { 'SellerName' => user.username }
111
+ query: {
112
+ 'SellerName' => user.username,
113
+ 'PageSize' => GunBroker::API::PAGE_SIZE
114
+ }
97
115
  )
98
116
  .to_return(body: response_fixture('items'))
99
117
 
@@ -114,7 +132,10 @@ describe GunBroker::User::ItemsDelegate do
114
132
  stub_request(:get, all_endpoint)
115
133
  .with(
116
134
  headers: headers('X-AccessToken' => token),
117
- query: { 'SellerName' => user.username }
135
+ query: {
136
+ 'SellerName' => user.username,
137
+ 'PageSize' => GunBroker::API::PAGE_SIZE
138
+ }
118
139
  )
119
140
  .to_return(body: response_fixture('items'))
120
141
 
@@ -131,7 +152,10 @@ describe GunBroker::User::ItemsDelegate do
131
152
  context 'on success' do
132
153
  it 'returns won Items' do
133
154
  stub_request(:get, endpoint)
134
- .with(headers: headers('X-AccessToken' => token))
155
+ .with(
156
+ headers: headers('X-AccessToken' => token),
157
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
158
+ )
135
159
  .to_return(body: response_fixture('items'))
136
160
 
137
161
  user = GunBroker::User.new(username, token: token)
@@ -143,7 +167,10 @@ describe GunBroker::User::ItemsDelegate do
143
167
  context 'on failure' do
144
168
  it 'raises an exception' do
145
169
  stub_request(:get, endpoint)
146
- .with(headers: headers('X-AccessToken' => token))
170
+ .with(
171
+ headers: headers('X-AccessToken' => token),
172
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
173
+ )
147
174
  .to_return(body: response_fixture('not_authorized'), status: 401)
148
175
 
149
176
  user = GunBroker::User.new(username, token: token)
@@ -158,7 +185,10 @@ describe GunBroker::User::ItemsDelegate do
158
185
  context 'on success' do
159
186
  it 'returns sold Items' do
160
187
  stub_request(:get, endpoint)
161
- .with(headers: headers('X-AccessToken' => token))
188
+ .with(
189
+ headers: headers('X-AccessToken' => token),
190
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
191
+ )
162
192
  .to_return(body: response_fixture('items'))
163
193
 
164
194
  user = GunBroker::User.new(username, token: token)
@@ -170,7 +200,10 @@ describe GunBroker::User::ItemsDelegate do
170
200
  context 'on failure' do
171
201
  it 'raises an exception' do
172
202
  stub_request(:get, endpoint)
173
- .with(headers: headers('X-AccessToken' => token))
203
+ .with(
204
+ headers: headers('X-AccessToken' => token),
205
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
206
+ )
174
207
  .to_return(body: response_fixture('not_authorized'), status: 401)
175
208
 
176
209
  user = GunBroker::User.new(username, token: token)
@@ -185,7 +218,10 @@ describe GunBroker::User::ItemsDelegate do
185
218
  context 'on success' do
186
219
  it 'returns unsold Items' do
187
220
  stub_request(:get, endpoint)
188
- .with(headers: headers('X-AccessToken' => token))
221
+ .with(
222
+ headers: headers('X-AccessToken' => token),
223
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
224
+ )
189
225
  .to_return(body: response_fixture('items'))
190
226
 
191
227
  user = GunBroker::User.new(username, token: token)
@@ -197,7 +233,10 @@ describe GunBroker::User::ItemsDelegate do
197
233
  context 'on failure' do
198
234
  it 'raises an exception' do
199
235
  stub_request(:get, endpoint)
200
- .with(headers: headers('X-AccessToken' => token))
236
+ .with(
237
+ headers: headers('X-AccessToken' => token),
238
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
239
+ )
201
240
  .to_return(body: response_fixture('not_authorized'), status: 401)
202
241
 
203
242
  user = GunBroker::User.new(username, token: token)
@@ -212,7 +251,10 @@ describe GunBroker::User::ItemsDelegate do
212
251
  context 'on success' do
213
252
  it 'returns won Items' do
214
253
  stub_request(:get, endpoint)
215
- .with(headers: headers('X-AccessToken' => token))
254
+ .with(
255
+ headers: headers('X-AccessToken' => token),
256
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
257
+ )
216
258
  .to_return(body: response_fixture('items'))
217
259
 
218
260
  user = GunBroker::User.new(username, token: token)
@@ -224,7 +266,10 @@ describe GunBroker::User::ItemsDelegate do
224
266
  context 'on failure' do
225
267
  it 'raises an exception' do
226
268
  stub_request(:get, endpoint)
227
- .with(headers: headers('X-AccessToken' => token))
269
+ .with(
270
+ headers: headers('X-AccessToken' => token),
271
+ query: { 'PageSize' => GunBroker::API::PAGE_SIZE }
272
+ )
228
273
  .to_return(body: response_fixture('not_authorized'), status: 401)
229
274
 
230
275
  user = GunBroker::User.new(username, token: token)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gun_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dale Campbell