peddler 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -7
- data/lib/mws/fulfillment_inbound_shipment/client.rb +8 -8
- data/lib/mws/fulfillment_outbound_shipment/client.rb +3 -2
- data/lib/mws/off_amazon_payments/client.rb +18 -16
- data/lib/mws/orders/client.rb +2 -1
- data/lib/mws/products/client.rb +12 -12
- data/lib/mws/recommendations/client.rb +2 -2
- data/lib/mws/reports/client.rb +1 -1
- data/lib/mws/sellers/client.rb +1 -0
- data/lib/mws/subscriptions/client.rb +9 -9
- data/lib/mws/webstore/client.rb +7 -7
- data/lib/peddler/client.rb +23 -14
- data/lib/peddler/marketplace.rb +1 -1
- data/lib/peddler/operation.rb +3 -2
- data/lib/peddler/structured_list.rb +1 -1
- data/lib/peddler/version.rb +1 -1
- data/test/helper.rb +14 -3
- data/test/integration/test_fulfillment_inbound_shipment.rb +1 -1
- data/test/integration/test_recommendations.rb +2 -1
- data/test/integration/test_subscriptions.rb +0 -1
- data/test/mws.yml.example +4 -4
- data/test/unit/mws/test_feeds_client.rb +1 -1
- data/test/unit/mws/test_fulfillment_inbound_shipment_client.rb +1 -1
- data/test/unit/mws/test_fulfillment_outbound_shipment_client.rb +19 -2
- data/test/unit/mws/test_off_amazon_payments_client.rb +14 -1
- data/test/unit/mws/test_products_client.rb +1 -1
- data/test/unit/mws/test_recommendations_client.rb +1 -1
- data/test/unit/mws/test_sellers_client.rb +12 -0
- data/test/unit/mws/test_subscriptions_client.rb +3 -3
- data/test/unit/mws/test_webstore_client.rb +2 -2
- data/test/unit/peddler/test_client.rb +36 -11
- data/test/unit/peddler/test_marketplace.rb +1 -1
- data/test/unit/peddler/test_operation.rb +10 -10
- data/test/unit/peddler/test_parser.rb +10 -3
- data/test/unit/peddler/test_xml_parser.rb +6 -2
- metadata +2 -4
- data/test/mws.yml.1 +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6f67b925cce300aac503662925a525c2a926db0
|
4
|
+
data.tar.gz: c50b916f201204efff20ad84142b890f87f18db8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b7207770118f4af6786a4394bfd1138b0b89c311e9b20059b9818ae75a84c4ed25f2ea4fd102740e5f98ffa1847e78d8536509e6b73cddf5fc0f4b1fefa6394
|
7
|
+
data.tar.gz: 171a182338ae07f4e52ddbf846fd12e963ec2c4dce6c9c18b38e8fd8c95f8e3e3148a44b24d264a9b6165158b3a9908ad7531a63a5eacd836c3b569c42f4b31e
|
data/README.md
CHANGED
@@ -34,16 +34,12 @@ Each client requires valid MWS credentials. You can set some or all when or afte
|
|
34
34
|
|
35
35
|
```ruby
|
36
36
|
client = MWS::Orders::Client.new(
|
37
|
-
|
38
|
-
merchant_id:
|
39
|
-
aws_access_key_id:
|
37
|
+
primary_marketplace_id: "foo",
|
38
|
+
merchant_id: "bar",
|
39
|
+
aws_access_key_id: "baz",
|
40
40
|
aws_secret_access_key: "qux"
|
41
41
|
)
|
42
42
|
|
43
|
-
# Swap marketplace
|
44
|
-
client.marketplace_id = "quux"
|
45
|
-
```
|
46
|
-
|
47
43
|
Alternatively, you can set these globally in the shell.
|
48
44
|
|
49
45
|
```sh
|
@@ -21,8 +21,8 @@ module MWS
|
|
21
21
|
def create_inbound_shipment_plan(ship_from_address, inbound_shipment_plan_request_items, opts = {})
|
22
22
|
operation('CreateInboundShipmentPlan')
|
23
23
|
.add(opts.update(
|
24
|
-
|
25
|
-
|
24
|
+
'ShipFromAddress' => ship_from_address,
|
25
|
+
'InboundShipmentPlanRequestItems' => inbound_shipment_plan_request_items
|
26
26
|
))
|
27
27
|
.structure!('InboundShipmentPlanRequestItems', 'member')
|
28
28
|
|
@@ -40,8 +40,8 @@ module MWS
|
|
40
40
|
def create_inbound_shipment(shipment_id, inbound_shipment_header, opts = {})
|
41
41
|
operation('CreateInboundShipment')
|
42
42
|
.add(opts.update(
|
43
|
-
|
44
|
-
|
43
|
+
'ShipmentId' => shipment_id,
|
44
|
+
'InboundShipmentHeader' => inbound_shipment_header
|
45
45
|
))
|
46
46
|
.structure!('InboundShipmentItems', 'member')
|
47
47
|
|
@@ -59,8 +59,8 @@ module MWS
|
|
59
59
|
def update_inbound_shipment(shipment_id, inbound_shipment_header, opts = {})
|
60
60
|
operation('UpdateInboundShipment')
|
61
61
|
.add(opts.update(
|
62
|
-
|
63
|
-
|
62
|
+
'ShipmentId' => shipment_id,
|
63
|
+
'InboundShipmentHeader' => inbound_shipment_header
|
64
64
|
))
|
65
65
|
.structure!('InboundShipmentItems', 'member')
|
66
66
|
|
@@ -142,8 +142,8 @@ module MWS
|
|
142
142
|
def get_package_labels(shipment_id, page_type, opts = {})
|
143
143
|
operation('GetPackageLabels')
|
144
144
|
.add(opts.update(
|
145
|
-
|
146
|
-
|
145
|
+
'ShipmentId' => shipment_id,
|
146
|
+
'PageType' => page_type
|
147
147
|
))
|
148
148
|
|
149
149
|
run
|
@@ -55,6 +55,7 @@ module MWS
|
|
55
55
|
# @option opts [Array<String>] :notification_email_list
|
56
56
|
# @option opts [Struct, Hash] :cod_settings
|
57
57
|
# @return [Peddler::XMLParser]
|
58
|
+
# rubocop:disable MethodLength, ParameterLists
|
58
59
|
def create_fulfillment_order(seller_fulfillment_order_id, displayable_order_id, displayable_order_date_time, displayable_order_comment, shipping_speed_category, destination_address, items, opts = {})
|
59
60
|
if opts.key?(:cod_settings)
|
60
61
|
opts['CODSettings'] = opts.delete(:cod_settings)
|
@@ -71,7 +72,7 @@ module MWS
|
|
71
72
|
'DestinationAddress' => destination_address,
|
72
73
|
'Items' => items
|
73
74
|
)
|
74
|
-
|
75
|
+
)
|
75
76
|
.structure!('Items', 'member')
|
76
77
|
.structure!('NotificationEmailList', 'member')
|
77
78
|
|
@@ -142,7 +143,7 @@ module MWS
|
|
142
143
|
# Returns delivery tracking information for a package in an outbound
|
143
144
|
# shipment for a Multi-Channel Fulfillment order
|
144
145
|
def get_package_tracking_details
|
145
|
-
|
146
|
+
fail NotImplementedError
|
146
147
|
end
|
147
148
|
|
148
149
|
# Requests that Amazon stop attempting to fulfill an existing fulfillment
|
@@ -13,6 +13,8 @@ module MWS
|
|
13
13
|
# made through the Login and Pay with Amazon service offered by Amazon
|
14
14
|
# Payments. You cannot use this API section to process payments for Amazon
|
15
15
|
# Marketplace, Amazon Webstore, or Checkout by Amazon.
|
16
|
+
#
|
17
|
+
# rubocop:disable ClassLength
|
16
18
|
class Client < ::Peddler::Client
|
17
19
|
version "2013-01-01"
|
18
20
|
path "/OffAmazonPayments/#{version}/"
|
@@ -38,8 +40,8 @@ module MWS
|
|
38
40
|
def create_order_reference_for_id(id, id_type, opts = {})
|
39
41
|
operation('CreateOrderReferenceForId')
|
40
42
|
.add(opts.update(
|
41
|
-
|
42
|
-
|
43
|
+
'Id' => id,
|
44
|
+
'IdType' => id_type
|
43
45
|
))
|
44
46
|
|
45
47
|
run
|
@@ -55,7 +57,7 @@ module MWS
|
|
55
57
|
def get_billing_agreement_details(amazon_billing_agreement_id, opts = {})
|
56
58
|
operation('GetBillingAgreementDetails')
|
57
59
|
.add(opts.update(
|
58
|
-
|
60
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id
|
59
61
|
))
|
60
62
|
|
61
63
|
run
|
@@ -128,9 +130,9 @@ module MWS
|
|
128
130
|
def authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, authorization_amount, opts = {})
|
129
131
|
operation('AuthorizeOnBillingAgreement')
|
130
132
|
.add(opts.update(
|
131
|
-
|
132
|
-
|
133
|
-
|
133
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id,
|
134
|
+
'AuthorizationReferenceId' => authorization_reference_id,
|
135
|
+
'AuthorizationAmount' => authorization_amount
|
134
136
|
))
|
135
137
|
|
136
138
|
run
|
@@ -148,7 +150,7 @@ module MWS
|
|
148
150
|
def close_billing_agreement(amazon_billing_agreement_id, opts = {})
|
149
151
|
operation('CloseBillingAgreement')
|
150
152
|
.add(opts.update(
|
151
|
-
|
153
|
+
'AmazonBillingAgreementId' => amazon_billing_agreement_id
|
152
154
|
))
|
153
155
|
|
154
156
|
run
|
@@ -248,9 +250,9 @@ module MWS
|
|
248
250
|
def authorize(amazon_order_reference_id, authorization_reference_id, authorization_amount, opts = {})
|
249
251
|
operation('Authorize')
|
250
252
|
.add(opts.update(
|
251
|
-
|
252
|
-
|
253
|
-
|
253
|
+
'AmazonOrderReferenceId' => amazon_order_reference_id,
|
254
|
+
'AuthorizationReferenceId' => authorization_reference_id,
|
255
|
+
'AuthorizationAmount' => authorization_amount
|
254
256
|
))
|
255
257
|
|
256
258
|
run
|
@@ -282,9 +284,9 @@ module MWS
|
|
282
284
|
def capture(amazon_authorization_id, capture_reference_id, capture_amount, opts = {})
|
283
285
|
operation('Capture')
|
284
286
|
.add(opts.update(
|
285
|
-
|
286
|
-
|
287
|
-
|
287
|
+
'AmazonAuthorizationId' => amazon_authorization_id,
|
288
|
+
'CaptureReferenceId' => capture_reference_id,
|
289
|
+
'CaptureAmount' => capture_amount
|
288
290
|
))
|
289
291
|
|
290
292
|
run
|
@@ -330,9 +332,9 @@ module MWS
|
|
330
332
|
def refund(amazon_capture_id, refund_reference_id, refund_amount, opts = {})
|
331
333
|
operation('Refund')
|
332
334
|
.add(opts.update(
|
333
|
-
|
334
|
-
|
335
|
-
|
335
|
+
'AmazonCaptureId' => amazon_capture_id,
|
336
|
+
'RefundReferenceId' => refund_reference_id,
|
337
|
+
'RefundAmount' => refund_amount
|
336
338
|
))
|
337
339
|
|
338
340
|
run
|
data/lib/mws/orders/client.rb
CHANGED
@@ -25,8 +25,9 @@ module MWS
|
|
25
25
|
# @option opts [String] :max_results_per_page
|
26
26
|
# @option opts [String] :tfm_shipment_status
|
27
27
|
# @return [Peddler::XMLParser]
|
28
|
+
# rubocop:disable MethodLength
|
28
29
|
def list_orders(opts = {})
|
29
|
-
opts[:marketplace_id] ||=
|
30
|
+
opts[:marketplace_id] ||= primary_marketplace_id
|
30
31
|
if opts.key?(:tfm_shipment_status)
|
31
32
|
opts['TFMShipmentStatus'] = opts.delete(:tfm_shipment_status)
|
32
33
|
end
|
data/lib/mws/products/client.rb
CHANGED
@@ -13,7 +13,7 @@ module MWS
|
|
13
13
|
# Lists products and their attributes, based on a search query
|
14
14
|
#
|
15
15
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_ListMatchingProducts.html
|
16
|
-
# @overload list_matching_products(query, opts = { marketplace_id:
|
16
|
+
# @overload list_matching_products(query, opts = { marketplace_id: primary_marketplace_id })
|
17
17
|
# @param query [String]
|
18
18
|
# @param opts [Hash]
|
19
19
|
# @option opts [String] :marketplace_id
|
@@ -30,7 +30,7 @@ module MWS
|
|
30
30
|
# SellerSKU, UPC, EAN, ISBN, and JAN values
|
31
31
|
#
|
32
32
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetMatchingProduct.html
|
33
|
-
# @overload get_matching_product_for_id(id_type, *id_list, opts = { marketplace_id:
|
33
|
+
# @overload get_matching_product_for_id(id_type, *id_list, opts = { marketplace_id: primary_marketplace_id })
|
34
34
|
# @param id_type [String]
|
35
35
|
# @param id_list [Array<String>]
|
36
36
|
# @param opts [Hash]
|
@@ -49,7 +49,7 @@ module MWS
|
|
49
49
|
# Lists products and their attributes, based on a list of ASIN values
|
50
50
|
#
|
51
51
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetMatchingProductForId.html
|
52
|
-
# @overload get_matching_product(*asin_list, opts = { marketplace_id:
|
52
|
+
# @overload get_matching_product(*asin_list, opts = { marketplace_id: primary_marketplace_id })
|
53
53
|
# @param asin_list [Array<String>]
|
54
54
|
# @param opts [Hash]
|
55
55
|
# @option opts [String] :marketplace_id
|
@@ -67,7 +67,7 @@ module MWS
|
|
67
67
|
# Gets the current competitive price of a product, based on Seller SKU
|
68
68
|
#
|
69
69
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetCompetitivePricingForSKU.html
|
70
|
-
# @overload get_competitive_pricing_for_sku(*seller_sku_list, opts = { marketplace_id:
|
70
|
+
# @overload get_competitive_pricing_for_sku(*seller_sku_list, opts = { marketplace_id: primary_marketplace_id })
|
71
71
|
# @param seller_sku_list [Array<String>]
|
72
72
|
# @param opts [Hash]
|
73
73
|
# @option opts [String] :marketplace_id
|
@@ -85,7 +85,7 @@ module MWS
|
|
85
85
|
# Gets the current competitive price of a product, identified by its ASIN
|
86
86
|
#
|
87
87
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetCompetitivePricingForASIN.html
|
88
|
-
# @overload get_competitive_pricing_for_asin(*asin_list, opts = { marketplace_id:
|
88
|
+
# @overload get_competitive_pricing_for_asin(*asin_list, opts = { marketplace_id: primary_marketplace_id })
|
89
89
|
# @param asin_list [Array<String>]
|
90
90
|
# @param opts [Hash]
|
91
91
|
# @option opts [String] :marketplace_id
|
@@ -104,7 +104,7 @@ module MWS
|
|
104
104
|
# a product, based on Seller SKU
|
105
105
|
#
|
106
106
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetLowestOfferListingsForSKU.html
|
107
|
-
# @overload get_lowest_offer_listings_for_sku(*seller_sku_list, opts = { marketplace_id:
|
107
|
+
# @overload get_lowest_offer_listings_for_sku(*seller_sku_list, opts = { marketplace_id: primary_marketplace_id })
|
108
108
|
# @param seller_sku_list [Array<String>]
|
109
109
|
# @param opts [Hash]
|
110
110
|
# @option opts [String] :marketplace_id
|
@@ -125,7 +125,7 @@ module MWS
|
|
125
125
|
# a product, identified by its ASIN
|
126
126
|
#
|
127
127
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetLowestOfferListingsForASIN.html
|
128
|
-
# @overload get_lowest_offer_listings_for_asin(*asin_list, opts = { marketplace_id:
|
128
|
+
# @overload get_lowest_offer_listings_for_asin(*asin_list, opts = { marketplace_id: primary_marketplace_id })
|
129
129
|
# @param asin_list [Array<String>]
|
130
130
|
# @param opts [Hash]
|
131
131
|
# @option opts [String] :marketplace_id
|
@@ -146,7 +146,7 @@ module MWS
|
|
146
146
|
# Seller SKU
|
147
147
|
#
|
148
148
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetMyPriceForSKU.html
|
149
|
-
# @overload get_my_price_for_sku(*seller_sku_list, opts = { marketplace_id:
|
149
|
+
# @overload get_my_price_for_sku(*seller_sku_list, opts = { marketplace_id: primary_marketplace_id })
|
150
150
|
# @param seller_sku_list [Array<String>]
|
151
151
|
# @param opts [Hash]
|
152
152
|
# @option opts [String] :marketplace_id
|
@@ -166,7 +166,7 @@ module MWS
|
|
166
166
|
# its ASIN
|
167
167
|
#
|
168
168
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetMyPriceForASIN.html
|
169
|
-
# @overload get_my_price_for_asin(*seller_sku_list, opts = { marketplace_id:
|
169
|
+
# @overload get_my_price_for_asin(*seller_sku_list, opts = { marketplace_id: primary_marketplace_id })
|
170
170
|
# @param asin_list [Array<String>]
|
171
171
|
# @param opts [Hash]
|
172
172
|
# @option opts [String] :marketplace_id
|
@@ -186,7 +186,7 @@ module MWS
|
|
186
186
|
# Seller`SKU
|
187
187
|
#
|
188
188
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetProductCategoriesForSKU.html
|
189
|
-
# @overload get_product_categories_for_sku(sku, opts = { marketplace_id:
|
189
|
+
# @overload get_product_categories_for_sku(sku, opts = { marketplace_id: primary_marketplace_id })
|
190
190
|
# @param seller_sku [String]
|
191
191
|
# @param opts [Hash]
|
192
192
|
# @option opts [String] :marketplace_id
|
@@ -201,7 +201,7 @@ module MWS
|
|
201
201
|
# Gets parent product categories that a product belongs to, based on ASIN
|
202
202
|
#
|
203
203
|
# @see http://docs.developer.amazonservices.com/en_US/products/Products_GetProductCategoriesForASIN.html
|
204
|
-
# @overload get_product_categories_for_asin(asin, opts = { marketplace_id:
|
204
|
+
# @overload get_product_categories_for_asin(asin, opts = { marketplace_id: primary_marketplace_id })
|
205
205
|
# @param asin [String]
|
206
206
|
# @param opts [Hash]
|
207
207
|
# @option opts [String] :marketplace_id
|
@@ -226,7 +226,7 @@ module MWS
|
|
226
226
|
def operation_with_marketplace(*args)
|
227
227
|
operation(*args).tap do |opts|
|
228
228
|
unless opts.key?('MarketplaceId')
|
229
|
-
opts.store('MarketplaceId',
|
229
|
+
opts.store('MarketplaceId', primary_marketplace_id)
|
230
230
|
end
|
231
231
|
end
|
232
232
|
end
|
@@ -17,7 +17,7 @@ module MWS
|
|
17
17
|
# @see http://docs.developer.amazonservices.com/en_US/recommendations/Recommendations_GetLastUpdatedTimeForRecommendations.html
|
18
18
|
# @param marketplace_id [String]
|
19
19
|
# @return [Peddler::XMLParser]
|
20
|
-
def get_last_updated_time_for_recommendations(marketplace_id =
|
20
|
+
def get_last_updated_time_for_recommendations(marketplace_id = primary_marketplace_id)
|
21
21
|
operation('GetLastUpdatedTimeForRecommendations')
|
22
22
|
.add('MarketplaceId' => marketplace_id)
|
23
23
|
|
@@ -35,7 +35,7 @@ module MWS
|
|
35
35
|
# @option opts [Array<Struct, Hash>] :category_query_list
|
36
36
|
# @return [Peddler::XMLParser]
|
37
37
|
def list_recommendations(opts = {})
|
38
|
-
opts[:marketplace_id] ||=
|
38
|
+
opts[:marketplace_id] ||= primary_marketplace_id
|
39
39
|
|
40
40
|
operation('ListRecommendations')
|
41
41
|
.add(opts)
|
data/lib/mws/reports/client.rb
CHANGED
@@ -188,7 +188,7 @@ module MWS
|
|
188
188
|
# @see http://docs.developer.amazonservices.com/en_US/reports/Reports_GetReportScheduleListByNextToken.html
|
189
189
|
# @raise [NotImplementedError]
|
190
190
|
def get_report_schedule_list_by_next_token(*)
|
191
|
-
|
191
|
+
fail NotImplementedError
|
192
192
|
end
|
193
193
|
|
194
194
|
# Count scheduled reports
|
data/lib/mws/sellers/client.rb
CHANGED
@@ -41,6 +41,7 @@ module MWS
|
|
41
41
|
# Gets the MWS Auth Token of the seller account
|
42
42
|
#
|
43
43
|
# @see http://docs.developer.amazonservices.com/en_US/auth_token/AuthToken_GetAuthToken.html
|
44
|
+
# @todo Remove this method after June 30, 2015 as it will no longer be available.
|
44
45
|
# @return [Peddler::XMLParser]
|
45
46
|
def get_auth_token
|
46
47
|
operation('GetAuthToken')
|
@@ -18,7 +18,7 @@ module MWS
|
|
18
18
|
# @param sqs_queue_url [String]
|
19
19
|
# @param marketplace_id [String]
|
20
20
|
# @return [Peddler::XMLParser]
|
21
|
-
def register_destination(sqs_queue_url, marketplace_id =
|
21
|
+
def register_destination(sqs_queue_url, marketplace_id = primary_marketplace_id)
|
22
22
|
operation('RegisterDestination')
|
23
23
|
.add('MarketplaceId' => marketplace_id)
|
24
24
|
.add(build_destination(sqs_queue_url))
|
@@ -32,7 +32,7 @@ module MWS
|
|
32
32
|
# @param sqs_queue_url [String]
|
33
33
|
# @param marketplace_id [String]
|
34
34
|
# @return [Peddler::XMLParser]
|
35
|
-
def deregister_destination(sqs_queue_url, marketplace_id =
|
35
|
+
def deregister_destination(sqs_queue_url, marketplace_id = primary_marketplace_id)
|
36
36
|
operation('DeregisterDestination')
|
37
37
|
.add('MarketplaceId' => marketplace_id)
|
38
38
|
.add(build_destination(sqs_queue_url))
|
@@ -45,7 +45,7 @@ module MWS
|
|
45
45
|
# @see http://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_ListRegisteredDestinations.html
|
46
46
|
# @param marketplace_id [String]
|
47
47
|
# @return [Peddler::XMLParser]
|
48
|
-
def list_registered_destinations(marketplace_id =
|
48
|
+
def list_registered_destinations(marketplace_id = primary_marketplace_id)
|
49
49
|
operation('ListRegisteredDestinations')
|
50
50
|
.add('MarketplaceId' => marketplace_id)
|
51
51
|
|
@@ -58,7 +58,7 @@ module MWS
|
|
58
58
|
# @param sqs_queue_url [String]
|
59
59
|
# @param marketplace_id [String]
|
60
60
|
# @return [Peddler::XMLParser]
|
61
|
-
def send_test_notification_to_destination(sqs_queue_url, marketplace_id =
|
61
|
+
def send_test_notification_to_destination(sqs_queue_url, marketplace_id = primary_marketplace_id)
|
62
62
|
operation('SendTestNotificationToDestination')
|
63
63
|
.add('MarketplaceId' => marketplace_id)
|
64
64
|
.add(build_destination(sqs_queue_url))
|
@@ -73,7 +73,7 @@ module MWS
|
|
73
73
|
# @param sqs_queue_url [String]
|
74
74
|
# @param marketplace_id [String]
|
75
75
|
# @return [Peddler::XMLParser]
|
76
|
-
def create_subscription(notification_type, sqs_queue_url, marketplace_id =
|
76
|
+
def create_subscription(notification_type, sqs_queue_url, marketplace_id = primary_marketplace_id)
|
77
77
|
operation('CreateSubscription')
|
78
78
|
.add('MarketplaceId' => marketplace_id)
|
79
79
|
.add(build_subscription(notification_type, sqs_queue_url))
|
@@ -88,7 +88,7 @@ module MWS
|
|
88
88
|
# @param sqs_queue_url [String]
|
89
89
|
# @param marketplace_id [String]
|
90
90
|
# @return [Peddler::XMLParser]
|
91
|
-
def get_subscription(notification_type, sqs_queue_url, marketplace_id =
|
91
|
+
def get_subscription(notification_type, sqs_queue_url, marketplace_id = primary_marketplace_id)
|
92
92
|
operation('GetSubscription')
|
93
93
|
.add(
|
94
94
|
'MarketplaceId' => marketplace_id,
|
@@ -106,7 +106,7 @@ module MWS
|
|
106
106
|
# @param sqs_queue_url [String]
|
107
107
|
# @param marketplace_id [String]
|
108
108
|
# @return [Peddler::XMLParser]
|
109
|
-
def delete_subscription(notification_type, sqs_queue_url, marketplace_id =
|
109
|
+
def delete_subscription(notification_type, sqs_queue_url, marketplace_id = primary_marketplace_id)
|
110
110
|
operation('DeleteSubscription')
|
111
111
|
.add(
|
112
112
|
'MarketplaceId' => marketplace_id,
|
@@ -122,7 +122,7 @@ module MWS
|
|
122
122
|
# @see http://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_ListSubscriptions.html
|
123
123
|
# @param marketplace_id [String]
|
124
124
|
# @return [Peddler::XMLParser]
|
125
|
-
def list_subscriptions(marketplace_id =
|
125
|
+
def list_subscriptions(marketplace_id = primary_marketplace_id)
|
126
126
|
operation('ListSubscriptions')
|
127
127
|
.add('MarketplaceId' => marketplace_id)
|
128
128
|
|
@@ -137,7 +137,7 @@ module MWS
|
|
137
137
|
# @param enabled [Boolean]
|
138
138
|
# @param marketplace_id [String]
|
139
139
|
# @return [Peddler::XMLParser]
|
140
|
-
def update_subscription(notification_type, sqs_queue_url, enabled, marketplace_id =
|
140
|
+
def update_subscription(notification_type, sqs_queue_url, enabled, marketplace_id = primary_marketplace_id)
|
141
141
|
operation('UpdateSubscription')
|
142
142
|
.add('MarketplaceId' => marketplace_id)
|
143
143
|
.add(build_subscription(notification_type, sqs_queue_url, enabled))
|
data/lib/mws/webstore/client.rb
CHANGED
@@ -2,8 +2,8 @@ require 'peddler/client'
|
|
2
2
|
|
3
3
|
module MWS
|
4
4
|
module Webstore
|
5
|
-
# With the Webstore API section of Amazon MWS, you can get
|
6
|
-
# Available
|
5
|
+
# With the Webstore API section of Amazon MWS, you can get "Email Me When
|
6
|
+
# Available" subscription information for items listed on your Amazon
|
7
7
|
# Webstore. The Webstore API section can help you plan your inventory
|
8
8
|
# replenishment cycle by enabling you to query for items that your customers
|
9
9
|
# subscribed to when they clicked the Email Me When Available button on your
|
@@ -29,7 +29,7 @@ module MWS
|
|
29
29
|
# @option opts [Array<String>] :seller_sku_list
|
30
30
|
# @return [Peddler::XMLParser]
|
31
31
|
def list_subscriptions_count(subscription_state, opts = {})
|
32
|
-
opts[:marketplace_id] ||=
|
32
|
+
opts[:marketplace_id] ||= primary_marketplace_id
|
33
33
|
if opts.key?(:seller_sku_list)
|
34
34
|
opts['SellerSKUList'] = opts.delete(:seller_sku_list)
|
35
35
|
end
|
@@ -65,12 +65,12 @@ module MWS
|
|
65
65
|
# @option opts [String, #iso8601] :date_range_end
|
66
66
|
# @return [Peddler::XMLParser]
|
67
67
|
def get_subscription_details(seller_sku, subscription_state, date_range_start, opts = {})
|
68
|
-
opts[:marketplace_id] ||=
|
68
|
+
opts[:marketplace_id] ||= primary_marketplace_id
|
69
69
|
operation('GetSubscriptionDetails')
|
70
70
|
.add(opts.update(
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
'SellerSKU' => seller_sku,
|
72
|
+
'SubscriptionState' => subscription_state,
|
73
|
+
'DateRangeStart' => date_range_start
|
74
74
|
))
|
75
75
|
|
76
76
|
run
|
data/lib/peddler/client.rb
CHANGED
@@ -8,6 +8,8 @@ module Peddler
|
|
8
8
|
# An abstract client
|
9
9
|
#
|
10
10
|
# Subclass to implement an MWS API section.
|
11
|
+
#
|
12
|
+
# rubocop:disable ClassLength
|
11
13
|
class Client
|
12
14
|
extend Forwardable
|
13
15
|
include Jeff
|
@@ -16,7 +18,7 @@ module Peddler
|
|
16
18
|
# @return [String]
|
17
19
|
attr_accessor :auth_token
|
18
20
|
|
19
|
-
attr_writer :merchant_id, :
|
21
|
+
attr_writer :merchant_id, :primary_marketplace_id, :path
|
20
22
|
|
21
23
|
# @api private
|
22
24
|
attr_writer :version
|
@@ -44,12 +46,7 @@ module Peddler
|
|
44
46
|
@parser ||= Parser
|
45
47
|
end
|
46
48
|
|
47
|
-
|
48
|
-
# @!parse attr_writer :parser
|
49
|
-
# @return [Object]
|
50
|
-
def parser=(parser)
|
51
|
-
@parser = parser
|
52
|
-
end
|
49
|
+
attr_writer :parser
|
53
50
|
|
54
51
|
# @api private
|
55
52
|
def path(path = nil)
|
@@ -61,7 +58,7 @@ module Peddler
|
|
61
58
|
version ? @version = version : @version
|
62
59
|
end
|
63
60
|
|
64
|
-
#
|
61
|
+
# Sets an error handler
|
65
62
|
# @yieldparam request [Excon::Request]
|
66
63
|
# @yieldparam response [Excon::Response]
|
67
64
|
def on_error(&blk)
|
@@ -72,7 +69,7 @@ module Peddler
|
|
72
69
|
|
73
70
|
def inherited(base)
|
74
71
|
base.params(params)
|
75
|
-
base.on_error
|
72
|
+
base.on_error(&@error_handler) if @error_handler
|
76
73
|
end
|
77
74
|
end
|
78
75
|
|
@@ -94,10 +91,20 @@ module Peddler
|
|
94
91
|
end
|
95
92
|
|
96
93
|
# The merchant's Marketplace ID
|
97
|
-
# @!parse attr_reader :
|
94
|
+
# @!parse attr_reader :primary_marketplace_id
|
98
95
|
# @return [String]
|
96
|
+
def primary_marketplace_id
|
97
|
+
@primary_marketplace_id ||= ENV['MWS_MARKETPLACE_ID']
|
98
|
+
end
|
99
|
+
|
100
|
+
# @deprecated Use {#primary_marketplace_id} instead.
|
99
101
|
def marketplace_id
|
100
|
-
@
|
102
|
+
@primary_marketplace_id
|
103
|
+
end
|
104
|
+
|
105
|
+
# @deprecated Use {#primary_marketplace_id=} instead.
|
106
|
+
def marketplace_id=(marketplace_id)
|
107
|
+
@primary_marketplace_id = marketplace_id
|
101
108
|
end
|
102
109
|
|
103
110
|
# The merchant's Seller ID
|
@@ -140,7 +147,7 @@ module Peddler
|
|
140
147
|
@headers ||= {}
|
141
148
|
end
|
142
149
|
|
143
|
-
#
|
150
|
+
# Sets an error handler
|
144
151
|
# @yieldparam request [Excon::Request]
|
145
152
|
# @yieldparam response [Excon::Response]
|
146
153
|
def on_error(&blk)
|
@@ -158,6 +165,7 @@ module Peddler
|
|
158
165
|
end
|
159
166
|
|
160
167
|
# @api private
|
168
|
+
# rubocop:disable AbcSize, MethodLength
|
161
169
|
def run
|
162
170
|
opts = defaults.merge(query: operation, headers: headers)
|
163
171
|
opts.store(:body, body) if body
|
@@ -169,7 +177,8 @@ module Peddler
|
|
169
177
|
handle_error(e) or raise
|
170
178
|
rescue NoMethodError => e
|
171
179
|
if e.message == "undefined method `new' for #{parser}"
|
172
|
-
warn "[DEPRECATION] `Parser.parse` is deprecated.
|
180
|
+
warn "[DEPRECATION] `Parser.parse` is deprecated. "\
|
181
|
+
"Please use `Parser.new` instead."
|
173
182
|
parser.parse(res, encoding)
|
174
183
|
else
|
175
184
|
raise
|
@@ -179,7 +188,7 @@ module Peddler
|
|
179
188
|
private
|
180
189
|
|
181
190
|
def find_marketplace
|
182
|
-
Marketplace.new(
|
191
|
+
Marketplace.new(primary_marketplace_id)
|
183
192
|
end
|
184
193
|
|
185
194
|
def content_type(str)
|
data/lib/peddler/marketplace.rb
CHANGED
data/lib/peddler/operation.rb
CHANGED
@@ -11,8 +11,8 @@ module Peddler
|
|
11
11
|
|
12
12
|
def structure!(*list_keys)
|
13
13
|
list_key = list_keys.shift
|
14
|
-
|
15
|
-
if found_key
|
14
|
+
found_key = keys.find { |key| key.end_with?(list_key) }
|
15
|
+
if found_key
|
16
16
|
builder = StructuredList.new(found_key, *list_keys)
|
17
17
|
vals = delete(found_key)
|
18
18
|
update(builder.build(vals))
|
@@ -21,6 +21,7 @@ module Peddler
|
|
21
21
|
self
|
22
22
|
end
|
23
23
|
|
24
|
+
# rubocop:disable AbcSize, MethodLength, PerceivedComplexity
|
24
25
|
def store(key, val)
|
25
26
|
key = camelize(key) if key.is_a?(Symbol)
|
26
27
|
|
data/lib/peddler/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
+
require 'simplecov'
|
1
2
|
require 'coveralls'
|
2
|
-
|
3
|
+
|
4
|
+
SimpleCov.formatters = [
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
|
9
|
+
SimpleCov.start do
|
10
|
+
add_filter '/test/'
|
11
|
+
minimum_coverage(99.62)
|
12
|
+
end
|
13
|
+
|
3
14
|
require 'minitest/autorun'
|
4
15
|
require 'yaml'
|
5
16
|
require 'vcr'
|
@@ -21,7 +32,7 @@ module Accounts
|
|
21
32
|
|
22
33
|
%w(mws.yml mws.yml.example).each do |path|
|
23
34
|
file = File.expand_path("../#{path}", __FILE__)
|
24
|
-
if File.
|
35
|
+
if File.exist?(file)
|
25
36
|
@data = YAML.load_file(file)
|
26
37
|
break
|
27
38
|
end
|
@@ -70,7 +81,7 @@ VCR.configure do |c|
|
|
70
81
|
|
71
82
|
c.default_cassette_options = {
|
72
83
|
match_requests_on: [:host, :path, matcher],
|
73
|
-
record:
|
84
|
+
record: !ENV['RECORD'] ? :none : :new_episodes
|
74
85
|
}
|
75
86
|
|
76
87
|
# So that fixtures do not depend on merchant credentials
|
@@ -3,7 +3,7 @@ require 'mws/fulfillment_inbound_shipment'
|
|
3
3
|
|
4
4
|
class TestFulfillmentInboundShipment < IntegrationTest
|
5
5
|
Address = Struct.new(:name, :address_line_1, :city, :state_or_province_code,
|
6
|
-
|
6
|
+
:postal_code, :country_code)
|
7
7
|
Item = Struct.new(:seller_sku, :quantity)
|
8
8
|
|
9
9
|
def test_creates_inbound_shipment_plan
|
data/test/mws.yml.example
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
-
|
1
|
+
- primary_marketplace_id: A2EUQ1WTGCTBG2
|
2
2
|
aws_access_key_id: AWS_ACCESS_KEY_ID
|
3
3
|
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
4
4
|
merchant_id: MERCHANT_ID
|
5
|
-
-
|
5
|
+
- primary_marketplace_id: A1PA6795UKMFR9
|
6
6
|
aws_access_key_id: AWS_ACCESS_KEY_ID
|
7
7
|
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
8
8
|
merchant_id: MERCHANT_ID
|
9
|
-
-
|
9
|
+
- primary_marketplace_id: A1VC38T7YXB528
|
10
10
|
aws_access_key_id: AWS_ACCESS_KEY_ID
|
11
11
|
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
12
12
|
merchant_id: MERCHANT_ID
|
13
|
-
-
|
13
|
+
- primary_marketplace_id: ATVPDKIKX0DER
|
14
14
|
aws_access_key_id: AWS_ACCESS_KEY_ID
|
15
15
|
aws_secret_access_key: AWS_SECRET_ACCESS_KEY
|
16
16
|
merchant_id: MERCHANT_ID
|
@@ -11,14 +11,16 @@ class TestMWSFulfillmentOutboundShipmentClient < MiniTest::Test
|
|
11
11
|
'Action' => 'GetFulfillmentPreview',
|
12
12
|
'Address.Foo' => '1',
|
13
13
|
'Items.member.1.Bar' => '2',
|
14
|
-
'ShippingSpeedCategories.1' => '3'
|
14
|
+
'ShippingSpeedCategories.1' => '3',
|
15
|
+
'IncludeCODFulfillmentPreview' => true
|
15
16
|
}
|
16
17
|
|
17
18
|
@client.stub(:run, nil) do
|
18
19
|
@client.get_fulfillment_preview(
|
19
20
|
{ 'Foo' => '1' },
|
20
21
|
[{ 'Bar' => '2' }],
|
21
|
-
shipping_speed_categories: ['3']
|
22
|
+
shipping_speed_categories: ['3'],
|
23
|
+
include_cod_fulfillment_preview: true
|
22
24
|
)
|
23
25
|
end
|
24
26
|
|
@@ -35,6 +37,7 @@ class TestMWSFulfillmentOutboundShipmentClient < MiniTest::Test
|
|
35
37
|
'ShippingSpeedCategory' => '5',
|
36
38
|
'DestinationAddress.Foo' => '1',
|
37
39
|
'Items.member.1.Bar' => '2',
|
40
|
+
'CODSettings.Foo' => '1',
|
38
41
|
'NotificationEmailList.member.1' => '1'
|
39
42
|
}
|
40
43
|
|
@@ -43,6 +46,7 @@ class TestMWSFulfillmentOutboundShipmentClient < MiniTest::Test
|
|
43
46
|
'1', '2', '3', '4', '5',
|
44
47
|
{ 'Foo' => '1' },
|
45
48
|
[{ 'Bar' => '2' }],
|
49
|
+
cod_settings: { 'Foo' => '1' },
|
46
50
|
notification_email_list: ['1']
|
47
51
|
)
|
48
52
|
end
|
@@ -94,6 +98,19 @@ class TestMWSFulfillmentOutboundShipmentClient < MiniTest::Test
|
|
94
98
|
assert_equal operation, @client.operation
|
95
99
|
end
|
96
100
|
|
101
|
+
def test_lists_all_fulfillment_orders_by_next_token
|
102
|
+
operation = {
|
103
|
+
'Action' => 'ListAllFulfillmentOrdersByNextToken',
|
104
|
+
'NextToken' => '1'
|
105
|
+
}
|
106
|
+
|
107
|
+
@client.stub(:run, nil) do
|
108
|
+
@client.list_all_fulfillment_orders_by_next_token('1')
|
109
|
+
end
|
110
|
+
|
111
|
+
assert_equal operation, @client.operation
|
112
|
+
end
|
113
|
+
|
97
114
|
def test_gets_package_tracking_details
|
98
115
|
assert_raises(NotImplementedError) do
|
99
116
|
@client.get_package_tracking_details
|
@@ -7,7 +7,7 @@ class TestMWSOffAmazonPaymentsClient < MiniTest::Test
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_sandboxes
|
10
|
-
@client.
|
10
|
+
@client.primary_marketplace_id = 'A1F83G8C2ARO7P'
|
11
11
|
refute_includes @client.aws_endpoint, 'Sandbox'
|
12
12
|
assert_includes @client.sandbox.aws_endpoint, 'Sandbox'
|
13
13
|
end
|
@@ -188,6 +188,19 @@ class TestMWSOffAmazonPaymentsClient < MiniTest::Test
|
|
188
188
|
assert_equal operation, @client.operation
|
189
189
|
end
|
190
190
|
|
191
|
+
def test_gets_authorization_details
|
192
|
+
operation = {
|
193
|
+
'Action' => 'GetAuthorizationDetails',
|
194
|
+
'AmazonAuthorizationId' => '1'
|
195
|
+
}
|
196
|
+
|
197
|
+
@client.stub(:run, nil) do
|
198
|
+
@client.get_authorization_details('1')
|
199
|
+
end
|
200
|
+
|
201
|
+
assert_equal operation, @client.operation
|
202
|
+
end
|
203
|
+
|
191
204
|
def test_captures
|
192
205
|
operation = {
|
193
206
|
'Action' => 'Capture',
|
@@ -26,7 +26,7 @@ class TestMWSRecommendationsClient < MiniTest::Test
|
|
26
26
|
'MarketplaceId' => '123'
|
27
27
|
}
|
28
28
|
|
29
|
-
@client.
|
29
|
+
@client.primary_marketplace_id = '123'
|
30
30
|
@client.stub(:run, nil) do
|
31
31
|
@client.list_recommendations(category_query_list: [{ 'Foo' => '1' }])
|
32
32
|
end
|
@@ -42,4 +42,16 @@ class TestMWSSellersClient < MiniTest::Test
|
|
42
42
|
|
43
43
|
assert_equal operation, @client.operation
|
44
44
|
end
|
45
|
+
|
46
|
+
def test_gets_auth_token
|
47
|
+
operation = {
|
48
|
+
'Action' => 'GetAuthToken'
|
49
|
+
}
|
50
|
+
|
51
|
+
@client.stub(:run, nil) do
|
52
|
+
@client.get_auth_token
|
53
|
+
end
|
54
|
+
|
55
|
+
assert_equal operation, @client.operation
|
56
|
+
end
|
45
57
|
end
|
@@ -4,7 +4,7 @@ require 'mws/subscriptions/client'
|
|
4
4
|
class TestMWSSubscriptionsClient < MiniTest::Test
|
5
5
|
def setup
|
6
6
|
@client = MWS::Subscriptions::Client.new
|
7
|
-
@client.
|
7
|
+
@client.primary_marketplace_id = '123'
|
8
8
|
end
|
9
9
|
|
10
10
|
def test_registers_destination
|
@@ -133,7 +133,7 @@ class TestMWSSubscriptionsClient < MiniTest::Test
|
|
133
133
|
operation = {
|
134
134
|
'Action' => 'CreateSubscription',
|
135
135
|
'MarketplaceId' => '123',
|
136
|
-
'Subscription.IsEnabled'=>true,
|
136
|
+
'Subscription.IsEnabled' => true,
|
137
137
|
'Subscription.NotificationType' => 'foo',
|
138
138
|
'Subscription.Destination.DeliveryChannel' => 'SQS',
|
139
139
|
'Subscription.Destination.AttributeList.member.1.Key' => 'sqsQueueUrl',
|
@@ -151,7 +151,7 @@ class TestMWSSubscriptionsClient < MiniTest::Test
|
|
151
151
|
operation = {
|
152
152
|
'Action' => 'CreateSubscription',
|
153
153
|
'MarketplaceId' => '321',
|
154
|
-
'Subscription.IsEnabled'=>true,
|
154
|
+
'Subscription.IsEnabled' => true,
|
155
155
|
'Subscription.NotificationType' => 'foo',
|
156
156
|
'Subscription.Destination.DeliveryChannel' => 'SQS',
|
157
157
|
'Subscription.Destination.AttributeList.member.1.Key' => 'sqsQueueUrl',
|
@@ -7,7 +7,7 @@ class TestMWSWebstoreClient < MiniTest::Test
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_lists_subscriptions_count
|
10
|
-
@client.
|
10
|
+
@client.primary_marketplace_id = '123'
|
11
11
|
operation = {
|
12
12
|
'Action' => 'ListSubscriptionsCount',
|
13
13
|
'MarketplaceId' => '123',
|
@@ -55,7 +55,7 @@ class TestMWSWebstoreClient < MiniTest::Test
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_get_subscriptions_details
|
58
|
-
@client.
|
58
|
+
@client.primary_marketplace_id = '123'
|
59
59
|
operation = {
|
60
60
|
'Action' => 'GetSubscriptionDetails',
|
61
61
|
'MarketplaceId' => '123',
|
@@ -4,7 +4,9 @@ require 'peddler/client'
|
|
4
4
|
|
5
5
|
class TestPeddlerClient < MiniTest::Test
|
6
6
|
module Parser
|
7
|
-
def self.new(res, *)
|
7
|
+
def self.new(res, *)
|
8
|
+
res
|
9
|
+
end
|
8
10
|
end
|
9
11
|
|
10
12
|
def setup
|
@@ -18,7 +20,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
18
20
|
@client.aws_access_key_id = 'key'
|
19
21
|
@client.aws_secret_access_key = 'secret'
|
20
22
|
@client.merchant_id = 'seller'
|
21
|
-
@client.
|
23
|
+
@client.primary_marketplace_id = 'ATVPDKIKX0DER' # US
|
22
24
|
@client.operation('Foo')
|
23
25
|
end
|
24
26
|
|
@@ -44,7 +46,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def test_has_user_agent
|
47
|
-
assert @client.connection.data[:headers].
|
49
|
+
assert @client.connection.data[:headers].key?('User-Agent')
|
48
50
|
end
|
49
51
|
|
50
52
|
def test_inherits_parents_params
|
@@ -80,7 +82,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
80
82
|
end
|
81
83
|
|
82
84
|
def test_sets_content_type_header_for_chinese_flat_file_body
|
83
|
-
@client.
|
85
|
+
@client.primary_marketplace_id = 'AAHKV2X7AFYLW'
|
84
86
|
@client.body = 'foo'
|
85
87
|
content_type = @client.headers.fetch('Content-Type')
|
86
88
|
|
@@ -88,7 +90,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def test_sets_content_type_header_for_japanese_flat_file_body
|
91
|
-
@client.
|
93
|
+
@client.primary_marketplace_id = 'A1VC38T7YXB528'
|
92
94
|
@client.body = 'foo'
|
93
95
|
content_type = @client.headers.fetch('Content-Type')
|
94
96
|
|
@@ -131,11 +133,11 @@ class TestPeddlerClient < MiniTest::Test
|
|
131
133
|
@client.run
|
132
134
|
headers = instrumentor.events['excon.request'][:headers]
|
133
135
|
|
134
|
-
assert headers.
|
136
|
+
assert headers.key?('User-Agent')
|
135
137
|
end
|
136
138
|
|
137
139
|
def test_error_callback_on_class
|
138
|
-
Excon.stub({},
|
140
|
+
Excon.stub({}, status: 503)
|
139
141
|
|
140
142
|
assert_raises(Excon::Errors::ServiceUnavailable) do
|
141
143
|
@client.run
|
@@ -152,7 +154,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
152
154
|
end
|
153
155
|
|
154
156
|
def test_error_callback_on_instance
|
155
|
-
Excon.stub({},
|
157
|
+
Excon.stub({}, status: 503)
|
156
158
|
|
157
159
|
assert_raises(Excon::Errors::ServiceUnavailable) do
|
158
160
|
@client.run
|
@@ -168,7 +170,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
168
170
|
end
|
169
171
|
|
170
172
|
def test_error_callback_on_client_ancestor
|
171
|
-
Excon.stub({},
|
173
|
+
Excon.stub({}, status: 503)
|
172
174
|
|
173
175
|
assert_raises(Excon::Errors::ServiceUnavailable) do
|
174
176
|
@client.run
|
@@ -184,7 +186,7 @@ class TestPeddlerClient < MiniTest::Test
|
|
184
186
|
client.aws_access_key_id = 'key'
|
185
187
|
client.aws_secret_access_key = 'secret'
|
186
188
|
client.merchant_id = 'seller'
|
187
|
-
client.
|
189
|
+
client.primary_marketplace_id = 'ATVPDKIKX0DER' # US
|
188
190
|
client.operation('Foo')
|
189
191
|
client.run
|
190
192
|
|
@@ -194,7 +196,9 @@ class TestPeddlerClient < MiniTest::Test
|
|
194
196
|
|
195
197
|
def test_deprecates_call_to_parser_parse
|
196
198
|
deprecated_parser = Module.new do
|
197
|
-
def self.parse(res, *)
|
199
|
+
def self.parse(res, *)
|
200
|
+
res
|
201
|
+
end
|
198
202
|
end
|
199
203
|
@client.stub :warn, nil do
|
200
204
|
@klass.parser = deprecated_parser
|
@@ -202,4 +206,25 @@ class TestPeddlerClient < MiniTest::Test
|
|
202
206
|
assert_equal @body, res.body
|
203
207
|
end
|
204
208
|
end
|
209
|
+
|
210
|
+
def test_raises_no_method_errors_not_related_to_deprecated_parser
|
211
|
+
bad_parser = Module.new do
|
212
|
+
def self.new(*)
|
213
|
+
fail NoMethodError, "foo"
|
214
|
+
end
|
215
|
+
end
|
216
|
+
@klass.parser = bad_parser
|
217
|
+
@client.stub :warn, nil do
|
218
|
+
assert_raises NoMethodError do
|
219
|
+
@client.run
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_deprecated_marketplace_id_accessor
|
225
|
+
refute_nil @client.marketplace_id
|
226
|
+
@client.marketplace_id = "123"
|
227
|
+
assert_equal "123", @client.marketplace_id
|
228
|
+
assert_equal @client.primary_marketplace_id, @client.marketplace_id
|
229
|
+
end
|
205
230
|
end
|
@@ -16,7 +16,7 @@ class TestPeddlerMarketplace < MiniTest::Test
|
|
16
16
|
|
17
17
|
def test_guard_against_missing_marketplace_id
|
18
18
|
assert_raises(Peddler::Marketplace::BadId, 'missing MarketplaceId') do
|
19
|
-
|
19
|
+
Peddler::Marketplace.new(nil)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -9,7 +9,7 @@ class TestPeddlerOperation < MiniTest::Test
|
|
9
9
|
def test_converts_key_to_structured_list
|
10
10
|
@operation.store('FooStatus', [1, 2])
|
11
11
|
@operation.structure!('FooStatus', 'Foo')
|
12
|
-
refute @operation.
|
12
|
+
refute @operation.key?('FooStatus')
|
13
13
|
assert_equal 1, @operation['FooStatus.Foo.1']
|
14
14
|
assert_equal 2, @operation['FooStatus.Foo.2']
|
15
15
|
end
|
@@ -17,20 +17,20 @@ class TestPeddlerOperation < MiniTest::Test
|
|
17
17
|
def test_converts_nested_key_to_structured_list
|
18
18
|
@operation.store('Foo.Status', [1])
|
19
19
|
@operation.structure!('Status', 'Bar')
|
20
|
-
refute @operation.
|
20
|
+
refute @operation.key?('FooStatus')
|
21
21
|
assert_equal 1, @operation['Foo.Status.Bar.1']
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_store_camelizes_key
|
25
25
|
@operation.store(:foo_bar, 'baz')
|
26
|
-
assert @operation.
|
27
|
-
refute @operation.
|
26
|
+
assert @operation.key?('FooBar')
|
27
|
+
refute @operation.key?(:foo_bar)
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_store_upcases_sku
|
31
31
|
@operation.store(:seller_sku, 'baz')
|
32
|
-
assert @operation.
|
33
|
-
refute @operation.
|
32
|
+
assert @operation.key?('SellerSKU')
|
33
|
+
refute @operation.key?(:seller_sku)
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_store_timestamps_time_values
|
@@ -42,15 +42,15 @@ class TestPeddlerOperation < MiniTest::Test
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def test_stringifies_hash_values
|
45
|
-
@operation.store('Foo',
|
45
|
+
@operation.store('Foo', bar: 1)
|
46
46
|
assert_equal 1, @operation.fetch('Foo.Bar')
|
47
|
-
refute @operation.
|
47
|
+
refute @operation.key?('Foo')
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_stringifies_nested_hash_values
|
51
|
-
@operation.store('Foo',
|
51
|
+
@operation.store('Foo', bar: { baz: 1 })
|
52
52
|
assert_equal 1, @operation.fetch('Foo.Bar.Baz')
|
53
|
-
refute @operation.
|
53
|
+
refute @operation.key?('Foo')
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_stringifies_struct_values
|
@@ -4,7 +4,10 @@ require 'peddler/parser'
|
|
4
4
|
class TestPeddlerParser < MiniTest::Test
|
5
5
|
def assert_parser(klass, *content_types)
|
6
6
|
content_types.each do |content_type|
|
7
|
-
res = OpenStruct.new(
|
7
|
+
res = OpenStruct.new(
|
8
|
+
headers: { 'Content-Type' => content_type },
|
9
|
+
body: ''
|
10
|
+
)
|
8
11
|
parser = Peddler::Parser.new(res)
|
9
12
|
|
10
13
|
assert_kind_of klass, parser
|
@@ -12,10 +15,14 @@ class TestPeddlerParser < MiniTest::Test
|
|
12
15
|
end
|
13
16
|
|
14
17
|
def test_parses_xml
|
15
|
-
assert_parser Peddler::XMLParser,
|
18
|
+
assert_parser Peddler::XMLParser,
|
19
|
+
'text/xml',
|
20
|
+
'text/xml; charset=UTF-8'
|
16
21
|
end
|
17
22
|
|
18
23
|
def test_parses_flat_files
|
19
|
-
assert_parser Peddler::FlatFileParser,
|
24
|
+
assert_parser Peddler::FlatFileParser,
|
25
|
+
'text/plain',
|
26
|
+
'application/octet-stream'
|
20
27
|
end
|
21
28
|
end
|
@@ -3,8 +3,12 @@ require 'peddler/xml_parser'
|
|
3
3
|
|
4
4
|
class TestPeddlerXMLParser < MiniTest::Test
|
5
5
|
def setup
|
6
|
-
body = '<Response><Result><NextToken>123</NextToken
|
7
|
-
|
6
|
+
body = '<Response><Result><NextToken>123</NextToken>'\
|
7
|
+
'<Foo>Bar</Foo></Result></Response>'
|
8
|
+
res = OpenStruct.new(
|
9
|
+
body: body,
|
10
|
+
headers: { 'Content-Type' => 'text/xml', 'Content-Length' => '78' }
|
11
|
+
)
|
8
12
|
|
9
13
|
@parser = Peddler::XMLParser.new(res)
|
10
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peddler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hakan Ensari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jeff
|
@@ -100,7 +100,6 @@ files:
|
|
100
100
|
- test/integration/test_sellers.rb
|
101
101
|
- test/integration/test_subscriptions.rb
|
102
102
|
- test/integration/test_webstore.rb
|
103
|
-
- test/mws.yml.1
|
104
103
|
- test/mws.yml.example
|
105
104
|
- test/unit/mws/test_cart_information_client.rb
|
106
105
|
- test/unit/mws/test_customer_information_client.rb
|
@@ -178,7 +177,6 @@ test_files:
|
|
178
177
|
- test/integration/test_sellers.rb
|
179
178
|
- test/integration/test_subscriptions.rb
|
180
179
|
- test/integration/test_webstore.rb
|
181
|
-
- test/mws.yml.1
|
182
180
|
- test/mws.yml.example
|
183
181
|
- test/unit/mws/test_cart_information_client.rb
|
184
182
|
- test/unit/mws/test_customer_information_client.rb
|
data/test/mws.yml.1
DELETED