peddler 1.6.5 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/peddler/client.rb +1 -1
- data/lib/peddler/errors/error.rb +2 -4
- data/lib/peddler/marketplace.rb +31 -55
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler/xml_parser.rb +1 -2
- data/test/helper.rb +5 -6
- data/test/unit/peddler/test_marketplace.rb +9 -10
- metadata +58 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f768c3add9b97c6d2af14872792feb553197fdb8
|
4
|
+
data.tar.gz: f33a7fd7ca78654a866191f0d2b5ac17629d0b38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 289d38d3d615f8f99c6695b4a665fdc6a464b104df4f23fc7bfcb4074c9689d02bead5e8418c3f8746e13ffb1f8cf0e94b021cbe9d8c65d2f614d3d946ba71d9
|
7
|
+
data.tar.gz: 628fdb1df72fe2e9164fb90c2dc4a7cbdd2307409e1b5ae9870756917c982474c3112ce33e212b38731e3e0412ae8b83719fef5bfe8f4b6c1f1e35b70ebe4b23
|
data/README.md
CHANGED
@@ -76,7 +76,7 @@ Peddler wraps successful responses in a parser that handles both XML documents a
|
|
76
76
|
```ruby
|
77
77
|
parser = client.get_service_status
|
78
78
|
parser.parse # will return a Hash object
|
79
|
-
parser.dig('Status') # delegates to Hash#dig
|
79
|
+
parser.dig('Status') # delegates to Hash#dig if available
|
80
80
|
```
|
81
81
|
|
82
82
|
You can swap the default parser with a purpose-built abstraction.
|
data/lib/peddler/client.rb
CHANGED
data/lib/peddler/errors/error.rb
CHANGED
@@ -3,15 +3,13 @@
|
|
3
3
|
module Peddler
|
4
4
|
# @api private
|
5
5
|
module Errors
|
6
|
-
#
|
6
|
+
# Here I curate error classes I see value in creating up front so we can use
|
7
|
+
# them for control flow. All other errors will be created at runtime.
|
7
8
|
CODES = %w[
|
8
9
|
AccessDenied
|
9
10
|
InternalError
|
10
11
|
InvalidAccessKeyId
|
11
12
|
InvalidMarketplace
|
12
|
-
InvalidParameterValue
|
13
|
-
InvalidRequest
|
14
|
-
MalformedInput
|
15
13
|
QuotaExceeded
|
16
14
|
RequestThrottled
|
17
15
|
].freeze
|
data/lib/peddler/marketplace.rb
CHANGED
@@ -3,53 +3,21 @@
|
|
3
3
|
module Peddler
|
4
4
|
# @api private
|
5
5
|
# @see https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}.freeze
|
22
|
-
|
23
|
-
HOSTS = {
|
24
|
-
'CA' => 'mws.amazonservices.com',
|
25
|
-
'MX' => 'mws.amazonservices.com',
|
26
|
-
'US' => 'mws.amazonservices.com',
|
27
|
-
'BR' => 'mws.amazonservices.com',
|
28
|
-
'DE' => 'mws-eu.amazonservices.com',
|
29
|
-
'ES' => 'mws-eu.amazonservices.com',
|
30
|
-
'FR' => 'mws-eu.amazonservices.com',
|
31
|
-
'IT' => 'mws-eu.amazonservices.com',
|
32
|
-
'UK' => 'mws-eu.amazonservices.com',
|
33
|
-
'IN' => 'mws.amazonservices.in',
|
34
|
-
'AU' => 'mws.amazonservices.com.au',
|
35
|
-
'JP' => 'mws.amazonservices.jp',
|
36
|
-
'CN' => 'mws.amazonservices.com.cn'
|
37
|
-
}.freeze
|
38
|
-
|
39
|
-
BadId = Class.new(StandardError)
|
40
|
-
|
41
|
-
attr_reader :id
|
42
|
-
|
43
|
-
def initialize(id)
|
44
|
-
@id = id || raise(BadId, 'missing MarketplaceId')
|
45
|
-
end
|
46
|
-
|
47
|
-
def country_code
|
48
|
-
@country_code ||= find_country_code
|
49
|
-
end
|
50
|
-
|
51
|
-
def host
|
52
|
-
@host ||= find_host
|
6
|
+
Marketplace = Struct.new(:id, :country_code, :host) do
|
7
|
+
class << self
|
8
|
+
attr_reader :all
|
9
|
+
|
10
|
+
def find(id)
|
11
|
+
all.find { |marketplace| marketplace.id == id } || begin
|
12
|
+
message = if id
|
13
|
+
%("#{id}" is not a valid MarketplaceId)
|
14
|
+
else
|
15
|
+
'missing MarketplaceId'
|
16
|
+
end
|
17
|
+
|
18
|
+
raise ArgumentError, message
|
19
|
+
end
|
20
|
+
end
|
53
21
|
end
|
54
22
|
|
55
23
|
# Caveat: We use the supersets Windows-31J and CP1252 in place of Shift_JIS
|
@@ -67,14 +35,22 @@ module Peddler
|
|
67
35
|
end
|
68
36
|
end
|
69
37
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
38
|
+
@all = [
|
39
|
+
['A2EUQ1WTGCTBG2', 'CA', 'mws.amazonservices.com'],
|
40
|
+
['A1AM78C64UM0Y8', 'MX', 'mws.amazonservices.com'],
|
41
|
+
['ATVPDKIKX0DER', 'US', 'mws.amazonservices.com'],
|
42
|
+
['A2Q3Y263D00KWC', 'BR', 'mws.amazonservices.com'],
|
43
|
+
['A1PA6795UKMFR9', 'DE', 'mws-eu.amazonservices.com'],
|
44
|
+
['A1RKKUPIHCS9HS', 'ES', 'mws-eu.amazonservices.com'],
|
45
|
+
['A13V1IB3VIYZZH', 'FR', 'mws-eu.amazonservices.com'],
|
46
|
+
['APJ6JRA9NG5V4', 'IT', 'mws-eu.amazonservices.com'],
|
47
|
+
['A1F83G8C2ARO7P', 'UK', 'mws-eu.amazonservices.com'],
|
48
|
+
['A21TJRUUN4KGV', 'IN', 'mws.amazonservices.in'],
|
49
|
+
['A39IBJ37TRP1C6', 'AU', 'mws.amazonservices.com.au'],
|
50
|
+
['A1VC38T7YXB528', 'JP', 'mws.amazonservices.jp'],
|
51
|
+
['AAHKV2X7AFYLW', 'CN', 'mws.amazonservices.com.cn']
|
52
|
+
].map do |values|
|
53
|
+
new(*values)
|
78
54
|
end
|
79
55
|
end
|
80
56
|
end
|
data/lib/peddler/version.rb
CHANGED
data/lib/peddler/xml_parser.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'delegate'
|
4
|
-
require 'dig_rb'
|
5
4
|
require 'forwardable'
|
6
5
|
require 'peddler/headers'
|
7
6
|
require 'multi_xml'
|
@@ -12,7 +11,7 @@ module Peddler
|
|
12
11
|
extend Forwardable
|
13
12
|
include Headers
|
14
13
|
|
15
|
-
def_delegator :parse, :dig
|
14
|
+
def_delegator :parse, :dig if Hash.method_defined?(:dig)
|
16
15
|
|
17
16
|
def parse
|
18
17
|
@data ||= find_data
|
data/test/helper.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
add_filter '/test/'
|
8
|
-
end
|
3
|
+
# Keep SimpleCov at top.
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter '/test/'
|
9
7
|
end
|
10
8
|
|
9
|
+
require 'backports/2.3.0/hash/dig'
|
11
10
|
require 'minitest/autorun'
|
12
11
|
require 'minitest/focus'
|
13
12
|
begin
|
@@ -5,31 +5,30 @@ require 'peddler/marketplace'
|
|
5
5
|
|
6
6
|
class TestPeddlerMarketplace < MiniTest::Test
|
7
7
|
def setup
|
8
|
-
@marketplace = Peddler::Marketplace.
|
8
|
+
@marketplace = Peddler::Marketplace.find('ATVPDKIKX0DER')
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
11
|
+
def test_country_code
|
12
12
|
assert @marketplace.country_code
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def test_host
|
16
16
|
assert @marketplace.host
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def test_encoding
|
20
20
|
assert @marketplace.encoding
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_guard_against_missing_marketplace_id
|
24
|
-
assert_raises(
|
25
|
-
Peddler::Marketplace.
|
24
|
+
assert_raises(ArgumentError, 'missing ID') do
|
25
|
+
Peddler::Marketplace.find(nil)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
30
|
-
assert_raises(
|
31
|
-
|
32
|
-
marketplace.host
|
29
|
+
def test_guard_against_invalid_marketplace_id
|
30
|
+
assert_raises(ArgumentError, '"123" is not a valid ID') do
|
31
|
+
Peddler::Marketplace.find('123')
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: dig_rb
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: excon
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,22 +28,16 @@ dependencies:
|
|
42
28
|
name: jeff
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
|
-
- - "
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 1.5.2
|
48
|
-
- - "<"
|
31
|
+
- - "~>"
|
49
32
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
33
|
+
version: '2.0'
|
51
34
|
type: :runtime
|
52
35
|
prerelease: false
|
53
36
|
version_requirements: !ruby/object:Gem::Requirement
|
54
37
|
requirements:
|
55
|
-
- - "
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version: 1.5.2
|
58
|
-
- - "<"
|
38
|
+
- - "~>"
|
59
39
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
40
|
+
version: '2.0'
|
61
41
|
- !ruby/object:Gem::Dependency
|
62
42
|
name: multi_xml
|
63
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,70 +196,70 @@ signing_key:
|
|
216
196
|
specification_version: 4
|
217
197
|
summary: Wraps the Amazon MWS APIs
|
218
198
|
test_files:
|
219
|
-
- test/
|
220
|
-
- test/
|
221
|
-
- test/
|
222
|
-
- test/
|
223
|
-
- test/
|
224
|
-
- test/
|
225
|
-
- test/
|
226
|
-
- test/
|
227
|
-
- test/
|
228
|
-
- test/
|
229
|
-
- test/
|
230
|
-
- test/
|
231
|
-
- test/
|
232
|
-
- test/
|
199
|
+
- test/credentials.rb
|
200
|
+
- test/helper.rb
|
201
|
+
- test/integration/test_errors.rb
|
202
|
+
- test/integration/test_feeds.rb
|
203
|
+
- test/integration/test_fulfillment_inbound_shipment.rb
|
204
|
+
- test/integration/test_fulfillment_inventory.rb
|
205
|
+
- test/integration/test_fulfillment_outbound_shipment.rb
|
206
|
+
- test/integration/test_merchant_fulfillment.rb
|
207
|
+
- test/integration/test_multibyte_queries.rb
|
208
|
+
- test/integration/test_mws_headers.rb
|
209
|
+
- test/integration/test_off_amazon_payments.rb
|
210
|
+
- test/integration/test_orders.rb
|
211
|
+
- test/integration/test_products.rb
|
212
|
+
- test/integration/test_recommendations.rb
|
213
|
+
- test/integration/test_reports.rb
|
214
|
+
- test/integration/test_sellers.rb
|
215
|
+
- test/integration/test_subscriptions.rb
|
216
|
+
- test/integration_helper.rb
|
217
|
+
- test/mws.yml.example
|
218
|
+
- test/null_client.rb
|
219
|
+
- test/recorder.rb
|
220
|
+
- test/unit/mws/test_feeds_client.rb
|
233
221
|
- test/unit/mws/test_finances_client.rb
|
234
|
-
- test/unit/mws/test_sellers_client.rb
|
235
222
|
- test/unit/mws/test_fulfillment_inbound_shipment_client.rb
|
223
|
+
- test/unit/mws/test_fulfillment_inventory_client.rb
|
224
|
+
- test/unit/mws/test_fulfillment_outbound_shipment_client.rb
|
236
225
|
- test/unit/mws/test_merchant_fulfillment_client.rb
|
237
|
-
- test/unit/mws/test_subscriptions_client.rb
|
238
226
|
- test/unit/mws/test_off_amazon_payments_client.rb
|
239
|
-
- test/unit/mws/test_reports_client.rb
|
240
|
-
- test/unit/mws/test_fulfillment_outbound_shipment_client.rb
|
241
227
|
- test/unit/mws/test_orders_client.rb
|
242
228
|
- test/unit/mws/test_products_client.rb
|
243
229
|
- test/unit/mws/test_recommendations_client.rb
|
244
|
-
- test/unit/mws/
|
245
|
-
- test/unit/mws/
|
230
|
+
- test/unit/mws/test_reports_client.rb
|
231
|
+
- test/unit/mws/test_sellers_client.rb
|
232
|
+
- test/unit/mws/test_subscriptions_client.rb
|
233
|
+
- test/unit/peddler/errors/test_builder.rb
|
234
|
+
- test/unit/peddler/errors/test_error.rb
|
235
|
+
- test/unit/peddler/errors/test_handler.rb
|
236
|
+
- test/unit/peddler/errors/test_parser.rb
|
237
|
+
- test/unit/peddler/test_client.rb
|
238
|
+
- test/unit/peddler/test_flat_file_parser.rb
|
239
|
+
- test/unit/peddler/test_headers.rb
|
240
|
+
- test/unit/peddler/test_marketplace.rb
|
241
|
+
- test/unit/peddler/test_operation.rb
|
242
|
+
- test/unit/peddler/test_parser.rb
|
243
|
+
- test/unit/peddler/test_structured_list.rb
|
244
|
+
- test/unit/peddler/test_vcr_matcher.rb
|
245
|
+
- test/unit/peddler/test_xml_parser.rb
|
246
|
+
- test/unit/peddler/test_xml_response_parser.rb
|
246
247
|
- test/unit/test_mws.rb
|
247
|
-
- test/
|
248
|
-
- test/mws.yml.example
|
249
|
-
- test/helper.rb
|
250
|
-
- test/integration/test_orders.rb
|
251
|
-
- test/integration/test_recommendations.rb
|
252
|
-
- test/integration/test_multibyte_queries.rb
|
253
|
-
- test/integration/test_feeds.rb
|
254
|
-
- test/integration/test_fulfillment_outbound_shipment.rb
|
255
|
-
- test/integration/test_fulfillment_inbound_shipment.rb
|
256
|
-
- test/integration/test_mws_headers.rb
|
257
|
-
- test/integration/test_reports.rb
|
258
|
-
- test/integration/test_subscriptions.rb
|
259
|
-
- test/integration/test_merchant_fulfillment.rb
|
260
|
-
- test/integration/test_errors.rb
|
261
|
-
- test/integration/test_sellers.rb
|
262
|
-
- test/integration/test_products.rb
|
263
|
-
- test/integration/test_off_amazon_payments.rb
|
264
|
-
- test/integration/test_fulfillment_inventory.rb
|
265
|
-
- test/integration_helper.rb
|
266
|
-
- test/vcr_cassettes/Products.yml
|
267
|
-
- test/vcr_cassettes/MerchantFulfillment.yml
|
248
|
+
- test/vcr_cassettes/CartInformation.yml
|
268
249
|
- test/vcr_cassettes/CustomerInformation.yml
|
269
|
-
- test/vcr_cassettes/
|
250
|
+
- test/vcr_cassettes/Errors.yml
|
270
251
|
- test/vcr_cassettes/Feeds.yml
|
271
|
-
- test/vcr_cassettes/Orders.yml
|
272
|
-
- test/vcr_cassettes/MultibyteQueries.yml
|
273
|
-
- test/vcr_cassettes/CartInformation.yml
|
274
252
|
- test/vcr_cassettes/FulfillmentInboundShipment.yml
|
253
|
+
- test/vcr_cassettes/FulfillmentInventory.yml
|
275
254
|
- test/vcr_cassettes/FulfillmentOutboundShipment.yml
|
276
|
-
- test/vcr_cassettes/
|
255
|
+
- test/vcr_cassettes/MerchantFulfillment.yml
|
256
|
+
- test/vcr_cassettes/MultibyteQueries.yml
|
257
|
+
- test/vcr_cassettes/MWSHeaders.yml
|
277
258
|
- test/vcr_cassettes/OffAmazonPayments.yml
|
259
|
+
- test/vcr_cassettes/Orders.yml
|
260
|
+
- test/vcr_cassettes/PeddlerVCRMatcher.yml
|
261
|
+
- test/vcr_cassettes/Products.yml
|
262
|
+
- test/vcr_cassettes/Recommendations.yml
|
263
|
+
- test/vcr_cassettes/Reports.yml
|
278
264
|
- test/vcr_cassettes/Sellers.yml
|
279
|
-
- test/vcr_cassettes/FulfillmentInventory.yml
|
280
|
-
- test/vcr_cassettes/Errors.yml
|
281
265
|
- test/vcr_cassettes/Subscriptions.yml
|
282
|
-
- test/vcr_cassettes/MWSHeaders.yml
|
283
|
-
- test/vcr_cassettes/Reports.yml
|
284
|
-
- test/recorder.rb
|
285
|
-
- test/credentials.rb
|