peddler 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mws/products/client.rb +43 -5
- data/lib/peddler/version.rb +1 -1
- data/test/integration/test_products.rb +7 -0
- data/test/mws.yml +16 -0
- data/test/unit/mws/test_products_client.rb +44 -0
- data/test/vcr_cassettes/Products.yml +1594 -28
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feb811340d856df7c73b3ea07afd4532892500c8
|
4
|
+
data.tar.gz: 537798c7e2eff288ac0d8e16094a8a295f9e2daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab7bc5600b29e18fe0968cd9dc874b9982ab50e4e6636b3390b0b46125b2e13eb1a1476e6064bdc2b4f889ede22fa97cd3d57c427530edc0e87c7d770e729594
|
7
|
+
data.tar.gz: 9a013902b6900d5e9cf6f0615a008816ec60e4761c758b8f8ba0ba10e3ec8e56547d8ad2f343695b38ab0cbb279ba03856364d2389bfbf9f77168d8a13128f7c
|
data/lib/mws/products/client.rb
CHANGED
@@ -142,6 +142,46 @@ module MWS
|
|
142
142
|
run
|
143
143
|
end
|
144
144
|
|
145
|
+
# Gets lowest priced offers for a single product, based on SellerSKU
|
146
|
+
#
|
147
|
+
# @see http://docs.developer.amazonservices.com/en_MX/products/Products_GetLowestPricedOffersForSKU.html
|
148
|
+
# @overload get_lowest_priced_offers_for_sku(seller_sku, item_condition, opts = { marketplace_id: primary_marketplace_id })
|
149
|
+
# @param seller_sku [String]
|
150
|
+
# @param item_condition [String]
|
151
|
+
# @param opts [Hash]
|
152
|
+
# @option opts [String] :marketplace_id
|
153
|
+
# @return [Peddler::XMLParser]
|
154
|
+
def get_lowest_priced_offers_for_sku(seller_sku, item_condition, opts = {})
|
155
|
+
opts.update(
|
156
|
+
'SellerSKU' => seller_sku,
|
157
|
+
'ItemCondition' => item_condition
|
158
|
+
)
|
159
|
+
operation_with_marketplace('GetLowestPricedOffersForSKU')
|
160
|
+
.add(opts)
|
161
|
+
|
162
|
+
run
|
163
|
+
end
|
164
|
+
|
165
|
+
# Gets lowest priced offers for a single product, based on ASIN
|
166
|
+
#
|
167
|
+
# @see http://docs.developer.amazonservices.com/en_MX/products/Products_GetLowestPricedOffersForASIN.html
|
168
|
+
# @overload get_lowest_priced_offers_for_sku(asin, item_condition, opts = { marketplace_id: primary_marketplace_id })
|
169
|
+
# @param asin [String]
|
170
|
+
# @param item_condition [String]
|
171
|
+
# @param opts [Hash]
|
172
|
+
# @option opts [String] :marketplace_id
|
173
|
+
# @return [Peddler::XMLParser]
|
174
|
+
def get_lowest_priced_offers_for_asin(asin, item_condition, opts = {})
|
175
|
+
opts.update(
|
176
|
+
'ASIN' => asin,
|
177
|
+
'ItemCondition' => item_condition
|
178
|
+
)
|
179
|
+
operation_with_marketplace('GetLowestPricedOffersForASIN')
|
180
|
+
.add(opts)
|
181
|
+
|
182
|
+
run
|
183
|
+
end
|
184
|
+
|
145
185
|
# Gets pricing information for seller's own offer listings, based on
|
146
186
|
# Seller SKU
|
147
187
|
#
|
@@ -223,11 +263,9 @@ module MWS
|
|
223
263
|
end
|
224
264
|
|
225
265
|
# @api private
|
226
|
-
def operation_with_marketplace(
|
227
|
-
operation(
|
228
|
-
|
229
|
-
opts.store('MarketplaceId', primary_marketplace_id)
|
230
|
-
end
|
266
|
+
def operation_with_marketplace(action)
|
267
|
+
operation(action).tap do |opts|
|
268
|
+
opts.store('MarketplaceId', primary_marketplace_id)
|
231
269
|
end
|
232
270
|
end
|
233
271
|
end
|
data/lib/peddler/version.rb
CHANGED
@@ -37,6 +37,13 @@ class TestProducts < IntegrationTest
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def test_gets_lowest_priced_offers_for_asin
|
41
|
+
clients.each do |client|
|
42
|
+
res = client.get_lowest_priced_offers_for_asin('1780935374', 'New')
|
43
|
+
refute_empty res.parse
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
40
47
|
def test_gets_product_categories_for_asin
|
41
48
|
clients.each do |client|
|
42
49
|
res = client.get_product_categories_for_asin('1780935374')
|
data/test/mws.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
- primary_marketplace_id: A2EUQ1WTGCTBG2
|
2
|
+
aws_access_key_id: AKIAITHQMZUJROSOP27Q
|
3
|
+
aws_secret_access_key: YDCmgpYmM5q2ucqLAeFUEbYKOAADvorsfJOgY5N6
|
4
|
+
merchant_id: A2A7WNXBU01UJW
|
5
|
+
- primary_marketplace_id: A1PA6795UKMFR9
|
6
|
+
aws_access_key_id: AKIAIORT7554FEBW7UBQ
|
7
|
+
aws_secret_access_key: P2ocOVChe/dQUpxRfA1n3TmP+wHrF6GaSzXslvEG
|
8
|
+
merchant_id: A7ZXDJZD3UIRG
|
9
|
+
- primary_marketplace_id: A1VC38T7YXB528
|
10
|
+
aws_access_key_id: AKIAJ5RDDSRROM6GXQ5Q
|
11
|
+
aws_secret_access_key: WGPMtwkUvlRXg22byoI+ceXyhnDQOMozUoFmsHzW
|
12
|
+
merchant_id: A7BU5WGNVGQ1I
|
13
|
+
- primary_marketplace_id: ATVPDKIKX0DER
|
14
|
+
aws_access_key_id: AKIAJ767ZET2BZR4UDDQ
|
15
|
+
aws_secret_access_key: rONa3ydPBTJ5JD0bxERTOX0Fv0fBK6Q986/cfMRO
|
16
|
+
merchant_id: A2H6NH4SQYFZ4M
|
@@ -92,6 +92,36 @@ class TestMWSProductsClient < MiniTest::Test
|
|
92
92
|
assert_equal operation, @client.operation
|
93
93
|
end
|
94
94
|
|
95
|
+
def test_gets_lowest_priced_offers_for_sku
|
96
|
+
operation = {
|
97
|
+
'Action' => 'GetLowestPricedOffersForSKU',
|
98
|
+
'MarketplaceId' => '123',
|
99
|
+
'SellerSKU' => '1',
|
100
|
+
'ItemCondition' => 'New'
|
101
|
+
}
|
102
|
+
|
103
|
+
@client.stub(:run, nil) do
|
104
|
+
@client.get_lowest_priced_offers_for_sku('1', 'New')
|
105
|
+
end
|
106
|
+
|
107
|
+
assert_equal operation, @client.operation
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_gets_lowest_priced_offers_for_asin
|
111
|
+
operation = {
|
112
|
+
'Action' => 'GetLowestPricedOffersForASIN',
|
113
|
+
'MarketplaceId' => '123',
|
114
|
+
'ASIN' => '1',
|
115
|
+
'ItemCondition' => 'New'
|
116
|
+
}
|
117
|
+
|
118
|
+
@client.stub(:run, nil) do
|
119
|
+
@client.get_lowest_priced_offers_for_asin('1', 'New')
|
120
|
+
end
|
121
|
+
|
122
|
+
assert_equal operation, @client.operation
|
123
|
+
end
|
124
|
+
|
95
125
|
def test_gets_lowest_offer_listings_for_asin
|
96
126
|
operation = {
|
97
127
|
'Action' => 'GetLowestOfferListingsForASIN',
|
@@ -162,6 +192,20 @@ class TestMWSProductsClient < MiniTest::Test
|
|
162
192
|
assert_equal operation, @client.operation
|
163
193
|
end
|
164
194
|
|
195
|
+
def test_queries_nonprimary_marketplaces
|
196
|
+
operation = {
|
197
|
+
'Action' => 'GetProductCategoriesForASIN',
|
198
|
+
'MarketplaceId' => '321',
|
199
|
+
'ASIN' => '1'
|
200
|
+
}
|
201
|
+
|
202
|
+
@client.stub(:run, nil) do
|
203
|
+
@client.get_product_categories_for_asin('1', marketplace_id: '321')
|
204
|
+
end
|
205
|
+
|
206
|
+
assert_equal operation, @client.operation
|
207
|
+
end
|
208
|
+
|
165
209
|
def test_gets_service_status
|
166
210
|
operation = {
|
167
211
|
'Action' => 'GetServiceStatus'
|