active_fulfillment 3.0.0.pre3 → 3.0.0.pre4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ff356b4c8f350a78ca0475c4415257fa803f83a9
|
4
|
+
data.tar.gz: 971bb598f5bd8ff27cb73eb0e0c5810453586714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d7ce7cbb4a2dd194df82e42f7677678e92ccecfa5b01b7f9990622252bfaac22cb2b8542fdb3f55c5c6a553ff35e4e460cf223087ccb1f070fc71ef136a451f
|
7
|
+
data.tar.gz: d1632004e3c03275a02bd0f1c2eabdef9cede7ca047fa75523d34a581d3ebc87466194d8701d2aa2c162fa092d1240b3a3c5f2e3be69aa782df284b85ebaf9c4
|
@@ -150,17 +150,20 @@ module ActiveFulfillment
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def fetch_tracking_data(order_ids, options = {})
|
153
|
+
index = 0
|
153
154
|
order_ids.reduce(nil) do |previous, order_id|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
155
|
+
index += 1
|
156
|
+
response = commit :post, :outbound, :tracking, build_tracking_request(order_id, options)
|
157
|
+
return response if !response.success?
|
158
|
+
|
159
|
+
if previous
|
160
|
+
sleep_for_throttle_options(options[:throttle], index)
|
161
|
+
response.tracking_numbers.merge!(previous.tracking_numbers)
|
162
|
+
response.tracking_companies.merge!(previous.tracking_companies)
|
163
|
+
response.tracking_urls.merge!(previous.tracking_urls)
|
164
|
+
end
|
162
165
|
|
163
|
-
|
166
|
+
response
|
164
167
|
end
|
165
168
|
end
|
166
169
|
|
@@ -460,6 +463,11 @@ module ActiveFulfillment
|
|
460
463
|
|
461
464
|
private
|
462
465
|
|
466
|
+
def sleep_for_throttle_options(throttle_options, index)
|
467
|
+
return unless interval = throttle_options.try(:[], :interval)
|
468
|
+
sleep(throttle_options[:sleep_time]) if (index % interval).zero?
|
469
|
+
end
|
470
|
+
|
463
471
|
def secure_compare(a, b)
|
464
472
|
return false unless a.bytesize == b.bytesize
|
465
473
|
|
@@ -381,6 +381,22 @@ class AmazonMarketplaceWebServiceTest < Minitest::Test
|
|
381
381
|
assert_equal %w{93ZZ00}, response.tracking_numbers['extern_id_1154539615776']
|
382
382
|
end
|
383
383
|
|
384
|
+
def test_fetch_tracking_numbers_with_throttle
|
385
|
+
@service.expects(:ssl_post).times(30).returns(xml_fixture('amazon_mws/fulfillment_get_fulfillment_order'))
|
386
|
+
numbers = (1..30).map {|i| "extern_id_#{i}" }
|
387
|
+
@service.expects(:sleep).times(3)
|
388
|
+
response = @service.fetch_tracking_numbers(numbers, {throttle: {interval: 10, sleep_time: 1}})
|
389
|
+
assert response.success?
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_fetch_tracking_numbers_with_throttle_for_not_enough_requests
|
393
|
+
@service.expects(:ssl_post).times(5).returns(xml_fixture('amazon_mws/fulfillment_get_fulfillment_order'))
|
394
|
+
numbers = (1..5).map {|i| "extern_id_#{i}" }
|
395
|
+
@service.expects(:sleep).never
|
396
|
+
response = @service.fetch_tracking_numbers(numbers, {throttle: {interval: 10, sleep_time: 1}})
|
397
|
+
assert response.success?
|
398
|
+
end
|
399
|
+
|
384
400
|
def test_fetch_tracking_numbers_aborts_on_error
|
385
401
|
response = mock('response')
|
386
402
|
response.stubs(:code).returns(500)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_fulfillment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.
|
4
|
+
version: 3.0.0.pre4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Fauser
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|