peddler 4.3.1 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +459 -109
- data/lib/peddler/api.rb +13 -11
- data/lib/peddler/apis/amazon_warehousing_and_distribution_2024_05_09.rb +7 -7
- data/lib/peddler/apis/aplus_content_2020_11_01.rb +10 -10
- data/lib/peddler/apis/application_integrations_2024_04_01.rb +1 -1
- data/lib/peddler/apis/catalog_items_2020_12_01.rb +8 -8
- data/lib/peddler/apis/catalog_items_2022_04_01.rb +9 -9
- data/lib/peddler/apis/customer_feedback_2024_06_01.rb +143 -0
- data/lib/peddler/apis/data_kiosk_2023_11_15.rb +4 -4
- data/lib/peddler/apis/fba_inbound_eligibility_v1.rb +1 -1
- data/lib/peddler/apis/fba_inventory_v1.rb +3 -3
- data/lib/peddler/apis/feeds_2021_06_30.rb +6 -6
- data/lib/peddler/apis/finances_2024_06_01.rb +1 -1
- data/lib/peddler/apis/finances_2024_06_19.rb +14 -6
- data/lib/peddler/apis/finances_v0.rb +2 -2
- data/lib/peddler/apis/fulfillment_inbound_2024_03_20.rb +40 -40
- data/lib/peddler/apis/fulfillment_inbound_v0.rb +8 -8
- data/lib/peddler/apis/fulfillment_outbound_2020_07_01.rb +7 -7
- data/lib/peddler/apis/invoices_2024_06_19.rb +4 -4
- data/lib/peddler/apis/listings_items_2020_09_01.rb +6 -6
- data/lib/peddler/apis/listings_items_2021_08_01.rb +20 -26
- data/lib/peddler/apis/listings_restrictions_2021_08_01.rb +1 -1
- data/lib/peddler/apis/merchant_fulfillment_v0.rb +2 -2
- data/lib/peddler/apis/messaging_v1.rb +26 -26
- data/lib/peddler/apis/notifications_v1.rb +6 -6
- data/lib/peddler/apis/orders_v0.rb +20 -20
- data/lib/peddler/apis/product_fees_v0.rb +2 -2
- data/lib/peddler/apis/product_pricing_v0.rb +6 -6
- data/lib/peddler/apis/product_type_definitions_2020_09_01.rb +4 -4
- data/lib/peddler/apis/reports_2021_06_30.rb +12 -9
- data/lib/peddler/apis/sales_v1.rb +7 -2
- data/lib/peddler/apis/seller_wallet_2024_03_01.rb +5 -5
- data/lib/peddler/apis/services_v1.rb +27 -27
- data/lib/peddler/apis/shipment_invoicing_v0.rb +3 -3
- data/lib/peddler/apis/shipping_v1.rb +5 -5
- data/lib/peddler/apis/shipping_v2.rb +6 -6
- data/lib/peddler/apis/solicitations_v1.rb +4 -4
- data/lib/peddler/apis/supply_sources_2020_07_01.rb +4 -4
- data/lib/peddler/apis/uploads_2020_11_01.rb +2 -2
- data/lib/peddler/apis/vendor_direct_fulfillment_inventory_v1.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_orders_2021_12_28.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_orders_v1.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_shipping_2021_12_28.rb +4 -4
- data/lib/peddler/apis/vendor_direct_fulfillment_shipping_v1.rb +3 -3
- data/lib/peddler/apis/vendor_direct_fulfillment_transactions_2021_12_28.rb +1 -1
- data/lib/peddler/apis/vendor_direct_fulfillment_transactions_v1.rb +1 -1
- data/lib/peddler/apis/vendor_orders_v1.rb +1 -1
- data/lib/peddler/apis/vendor_shipments_v1.rb +1 -1
- data/lib/peddler/apis/vendor_transaction_status_v1.rb +1 -1
- data/lib/peddler/config.rb +17 -0
- data/lib/peddler/error.rb +35 -8
- data/lib/peddler/helpers/feeds_2021_06_30.rb +22 -8
- data/lib/peddler/helpers/reports_2021_06_30.rb +38 -0
- data/lib/peddler/marketplace.rb +14 -0
- data/lib/peddler/response.rb +52 -5
- data/lib/peddler/token.rb +4 -15
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler.rb +54 -0
- metadata +8 -13
- data/lib/peddler/parsers/openapi_parser_generator.rb +0 -550
- data/lib/peddler/parsers/smart_parser.rb +0 -199
data/README.md
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
|
5
5
|
**Peddler** is a Ruby interface to the [Amazon Selling Partner API (SP-API)][docs-overview]. The SP-API enables Amazon sellers and vendors to programmatically access their data on orders, shipments, payments, and more.
|
6
6
|
|
7
|
-
Peddler is automatically generated from the Open API models provided by Amazon.
|
7
|
+
Peddler is automatically generated from the latest Open API models provided by Amazon.
|
8
8
|
|
9
9
|
To begin using the Amazon SP-API, you must [register as a developer][register-as-developer] and [register your application][register-application]. Once registered, [obtain your Login with Amazon (LWA) credentials][view-credentials] to access your own or other selling partners' data.
|
10
10
|
|
11
11
|
- [API models][api-models]
|
12
12
|
- [API samples][api-samples]
|
13
13
|
|
14
|
-
|
14
|
+
<img src="https://github.com/hakanensari/peddler/blob/main/images/peddler.jpg?raw=true" alt="Peddler" style="max-width: 830px" />
|
15
15
|
|
16
16
|
## Installation
|
17
17
|
|
@@ -27,6 +27,16 @@ And then execute:
|
|
27
27
|
bundle install
|
28
28
|
```
|
29
29
|
|
30
|
+
### Optional Dependencies
|
31
|
+
|
32
|
+
For enhanced error handling when uploading or downloading files, Peddler can parse XML error responses from Amazon S3 if Nokogiri is available:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
gem "nokogiri"
|
36
|
+
```
|
37
|
+
|
38
|
+
If Nokogiri is not available, S3 XML errors will still be handled gracefully, but with less detailed error information.
|
39
|
+
|
30
40
|
## Usage
|
31
41
|
|
32
42
|
Set your LWA credentials in your environment.
|
@@ -102,8 +112,6 @@ Amazon's SP-API imposes [rate limits][rate-limits] on operations. Override the d
|
|
102
112
|
|
103
113
|
Provide an optional `:retries` argument when initializing an API to specify retry attempts if throttled. Default is 0 (no retries). If set to a positive value, Peddler will retry with exponential backoff based on the rate limit.
|
104
114
|
|
105
|
-
**Note:** This functionality requires version 6 of the [HTTP library][httprb], which is not yet released. To use rate limiting, point to their main branch on GitHub.
|
106
|
-
|
107
115
|
```ruby
|
108
116
|
api = Peddler.orders_v0(aws_region, access_token, retries: 3)
|
109
117
|
api.get_orders(
|
@@ -112,132 +120,178 @@ api.get_orders(
|
|
112
120
|
)
|
113
121
|
```
|
114
122
|
|
115
|
-
###
|
123
|
+
### Error Handling
|
116
124
|
|
117
|
-
|
125
|
+
By default, Peddler v4 maintains backward compatibility:
|
126
|
+
- **Client errors (4xx)**: Always raise `Peddler::Error` exceptions
|
127
|
+
- **Server errors (5xx)**: Return response objects (deprecated behavior)
|
128
|
+
|
129
|
+
To adopt the recommended v5.0 behavior where all errors raise exceptions:
|
118
130
|
|
119
131
|
```ruby
|
120
|
-
|
132
|
+
Peddler.configure do |config|
|
133
|
+
config.raise_on_server_errors = true
|
134
|
+
end
|
121
135
|
```
|
122
136
|
|
123
|
-
|
124
|
-
|
125
|
-
#### Orders API (v0)
|
137
|
+
This ensures consistent error handling and prevents silent failures from server errors.
|
126
138
|
|
127
|
-
|
139
|
+
#### Current Default Behavior (v4.x)
|
128
140
|
|
129
141
|
```ruby
|
130
|
-
|
131
|
-
response = api.get_orders(
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
142
|
+
# Server errors (5xx) return response objects by default
|
143
|
+
response = api.get_orders(marketplaceIds: ["ATVPDKIKX0DER"])
|
144
|
+
|
145
|
+
# Must check status to detect server errors
|
146
|
+
if response.status >= 500
|
147
|
+
puts "Server error: #{response.status}"
|
148
|
+
# Handle error or retry
|
149
|
+
else
|
150
|
+
orders = response.parse["payload"]["orders"]
|
151
|
+
end
|
152
|
+
|
153
|
+
# Client errors (4xx) always raise
|
154
|
+
begin
|
155
|
+
response = api.get_orders(marketplaceIds: ["INVALID"])
|
156
|
+
rescue Peddler::Error => e
|
157
|
+
puts "Client error: #{e.message}"
|
158
|
+
end
|
136
159
|
```
|
137
160
|
|
138
|
-
####
|
161
|
+
#### Recommended Behavior (v5.0)
|
139
162
|
|
140
|
-
|
163
|
+
Enable consistent error handling by setting `raise_on_server_errors`:
|
141
164
|
|
142
165
|
```ruby
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
166
|
+
# Configure once at application startup
|
167
|
+
Peddler.configure do |config|
|
168
|
+
config.raise_on_server_errors = true
|
169
|
+
end
|
170
|
+
|
171
|
+
# Now all errors raise exceptions consistently
|
172
|
+
begin
|
173
|
+
response = api.get_orders(marketplaceIds: ["ATVPDKIKX0DER"])
|
174
|
+
orders = response.parse["payload"]["orders"]
|
175
|
+
rescue Peddler::Error => e
|
176
|
+
puts "API Error: #{e.message}"
|
177
|
+
puts "Status: #{e.response.status}"
|
178
|
+
|
179
|
+
# Handle retries for server errors
|
180
|
+
if e.response.status >= 500
|
181
|
+
# Retry logic here
|
182
|
+
end
|
183
|
+
end
|
149
184
|
```
|
150
185
|
|
151
|
-
####
|
186
|
+
#### S3 Error Handling
|
152
187
|
|
153
|
-
|
188
|
+
For file upload/download operations, Amazon S3 may return XML error responses. If Nokogiri is available, these are parsed for detailed error information:
|
154
189
|
|
155
190
|
```ruby
|
156
|
-
|
191
|
+
# With Nokogiri gem
|
192
|
+
gem "nokogiri"
|
193
|
+
|
194
|
+
# Enhanced S3 error parsing
|
195
|
+
begin
|
196
|
+
api.upload_document(document_data)
|
197
|
+
rescue Peddler::Error => e
|
198
|
+
puts "S3 Error: #{e.message}" # Detailed XML-parsed error
|
199
|
+
end
|
200
|
+
```
|
157
201
|
|
158
|
-
|
159
|
-
document_response = api.create_feed_document(
|
160
|
-
contentType: "text/xml; charset=UTF-8"
|
161
|
-
)
|
162
|
-
feed_document_id = document_response.parse["feedDocumentId"]
|
163
|
-
upload_url = document_response.parse["url"]
|
202
|
+
Without Nokogiri, S3 XML errors are still handled gracefully but with less detailed information.
|
164
203
|
|
165
|
-
|
166
|
-
feed_content = File.read("inventory_update.xml")
|
167
|
-
api.upload_feed_document(upload_url, feed_content, "text/xml; charset=UTF-8")
|
204
|
+
### Available APIs
|
168
205
|
|
169
|
-
|
170
|
-
feed_response = api.create_feed(
|
171
|
-
feedType: "POST_INVENTORY_AVAILABILITY_DATA",
|
172
|
-
marketplaceIds: ["ATVPDKIKX0DER"],
|
173
|
-
inputFeedDocumentId: feed_document_id
|
174
|
-
)
|
175
|
-
feed_id = feed_response.parse["feedId"]
|
176
|
-
```
|
206
|
+
Peddler provides Ruby interfaces to all Amazon SP-API endpoints. Each API is available in its respective version. Access APIs by calling methods on the Peddler module:
|
177
207
|
|
178
|
-
|
208
|
+
```ruby
|
209
|
+
api = Peddler.<api_name>_<version>(aws_region, access_token, options)
|
210
|
+
```
|
179
211
|
|
180
|
-
|
212
|
+
You can also simply initialize the latest version:
|
181
213
|
|
182
214
|
```ruby
|
183
|
-
api = Peddler
|
215
|
+
api = Peddler.<api_name>(aws_region, access_token, options)
|
216
|
+
```
|
184
217
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
218
|
+
Below is a comprehensive list of all available APIs organized by category:
|
219
|
+
|
220
|
+
#### Orders and Financial APIs
|
221
|
+
|
222
|
+
- **Orders API (v0)**: Retrieve and manage orders
|
223
|
+
- **Finances API (2024-06-19, 2024-06-01, v0)**: Get financial data including transaction details, payments, and refunds
|
224
|
+
- **Invoices API (2024-06-19)**: Manage billing invoices
|
225
|
+
- **Sales API (v1)**: Get order metrics and sales data
|
226
|
+
|
227
|
+
```ruby
|
228
|
+
api = Peddler.orders(aws_region, access_token)
|
229
|
+
response = api.get_orders(
|
230
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
231
|
+
createdAfter: "2023-01-01T00:00:00Z"
|
189
232
|
)
|
190
|
-
report_id = create_response.parse["reportId"]
|
191
233
|
|
192
|
-
#
|
193
|
-
|
234
|
+
# Use the `dig` method to safely navigate through nested response data
|
235
|
+
# This returns nil instead of raising an error if any key in the path doesn't exist
|
236
|
+
orders = response.dig("payload", "orders")
|
194
237
|
|
195
|
-
#
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
# Download report from URL
|
201
|
-
end
|
202
|
-
```
|
238
|
+
# You can chain multiple keys to access deeply nested data
|
239
|
+
first_order_id = response.dig("payload", "orders", 0, "amazonOrderId")
|
240
|
+
|
241
|
+
# This is safer than using chain indexing which would raise an error if any part is missing:
|
242
|
+
# response.parse["payload"]["orders"][0]["amazonOrderId"] # Error prone!
|
203
243
|
|
204
|
-
|
244
|
+
# For sandbox testing
|
245
|
+
api.sandbox.get_orders(
|
246
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
247
|
+
createdAfter: "TEST_CASE_200"
|
248
|
+
)
|
249
|
+
```
|
205
250
|
|
206
|
-
|
251
|
+
#### Catalog and Listing APIs
|
207
252
|
|
253
|
+
- **Catalog Items API (2022-04-01, 2020-12-01, v0)**: Access Amazon's catalog data
|
208
254
|
- **Listings Items API (2021-08-01, 2020-09-01)**: Create and update listings
|
209
255
|
- **Listings Restrictions API (2021-08-01)**: Check listing eligibility
|
210
256
|
- **Product Type Definitions API (2020-09-01)**: Get schema requirements for listings
|
257
|
+
- **A+ Content API (2020-11-01)**: Create and manage enhanced marketing content
|
258
|
+
- **Product Pricing API (2022-05-01, v0)**: Get pricing information
|
259
|
+
- **Product Fees API (v0)**: Retrieve fee estimates for products
|
211
260
|
|
212
261
|
```ruby
|
213
|
-
api = Peddler.
|
214
|
-
api.
|
215
|
-
|
216
|
-
"
|
217
|
-
"ATVPDKIKX0DER",
|
218
|
-
body: {
|
219
|
-
productType: "LUGGAGE",
|
220
|
-
requirements: "LISTING",
|
221
|
-
attributes: {
|
222
|
-
title: [{ value: "Travel Backpack" }],
|
223
|
-
manufacturer: [{ value: "Brand Name" }]
|
224
|
-
}
|
225
|
-
}
|
262
|
+
api = Peddler.catalog_items(aws_region, access_token)
|
263
|
+
response = api.get_catalog_item(
|
264
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
265
|
+
asin: "B08N5WRWNW"
|
226
266
|
)
|
227
|
-
|
267
|
+
item_details = response.dig("payload")
|
228
268
|
|
229
|
-
|
269
|
+
# Search catalog items by identifier
|
270
|
+
response = api.search_catalog_items(
|
271
|
+
["ATVPDKIKX0DER"],
|
272
|
+
identifiers: "B08N5WRWNW",
|
273
|
+
identifiers_type: "ASIN"
|
274
|
+
)
|
275
|
+
search_results = response.parse
|
276
|
+
```
|
230
277
|
|
231
|
-
|
278
|
+
#### Fulfillment and Inventory APIs
|
232
279
|
|
233
280
|
- **Fulfillment Inbound API (2024-03-20, v0)**: Send inventory to FBA
|
234
281
|
- **Fulfillment Outbound API (2020-07-01)**: Create and track FBA orders
|
235
282
|
- **FBA Inventory API (v1)**: Manage FBA inventory quantities
|
283
|
+
- **FBA Inbound Eligibility API (v1)**: Check product eligibility for FBA
|
236
284
|
- **Merchant Fulfillment API (v0)**: Create shipping labels for self-fulfilled orders
|
285
|
+
- **Easy Ship API (2022-03-23)**: Manage Amazon's carrier service for deliveries
|
286
|
+
- **Shipping APIs (v1, v2)**: Create shipments and purchase shipping labels
|
287
|
+
- **Replenishment API (2022-11-07)**: Manage inventory replenishment
|
288
|
+
- **Amazon Warehousing and Distribution API (2024-05-09)**: Manage fulfillment warehousing
|
289
|
+
- **Supply Sources API (2020-07-01)**: Manage supply/inventory sources
|
290
|
+
- **Shipment Invoicing API (v0)**: Manage shipment-related invoices
|
237
291
|
|
238
292
|
```ruby
|
239
293
|
# FBA outbound example
|
240
|
-
api = Peddler.
|
294
|
+
api = Peddler.fulfillment_outbound(aws_region, access_token)
|
241
295
|
api.create_fulfillment_order(
|
242
296
|
body: {
|
243
297
|
sellerFulfillmentOrderId: "ORDER123",
|
@@ -263,24 +317,143 @@ api.create_fulfillment_order(
|
|
263
317
|
)
|
264
318
|
```
|
265
319
|
|
266
|
-
####
|
320
|
+
#### Data Management APIs
|
267
321
|
|
268
|
-
|
322
|
+
- **Feeds API (2021-06-30)**: Upload data to Amazon to update listings, prices, inventory, and more
|
323
|
+
- **Reports API (2021-06-30)**: Request and download reports about orders, inventory, fulfillment, and more
|
324
|
+
- **Uploads API (2020-11-01)**: Upload files for various SP-API operations
|
325
|
+
- **Data Kiosk API (2023-11-15)**: Access and manage analytical data
|
269
326
|
|
270
327
|
```ruby
|
271
|
-
api = Peddler.
|
272
|
-
|
273
|
-
|
328
|
+
api = Peddler.feeds(aws_region, access_token)
|
329
|
+
|
330
|
+
# Complete Feeds API Workflow:
|
331
|
+
# 1. Create a feed document (input feed document)
|
332
|
+
# 2. Upload content to the document
|
333
|
+
# 3. Create feed referencing the document
|
334
|
+
# 4. Wait for feed to complete (e.g., SQS notification)
|
335
|
+
# 5. Get feed document (result feed document)
|
336
|
+
# 6. Download results to see processing outcome
|
337
|
+
|
338
|
+
# Step 1: Create feed document (input document)
|
339
|
+
document_response = api.create_feed_document(
|
340
|
+
contentType: "text/xml; charset=UTF-8"
|
274
341
|
)
|
275
|
-
|
342
|
+
|
343
|
+
# The `dig` method safely navigates the response hash
|
344
|
+
# If the response structure is:
|
345
|
+
# {
|
346
|
+
# "feedDocumentId": "amzn1.tortuga.3.abc123...",
|
347
|
+
# "url": "https://s3.amazonaws.com/bucket/key...",
|
348
|
+
# "encryptionDetails": {
|
349
|
+
# "standard": "AES",
|
350
|
+
# "key": "encryption-key",
|
351
|
+
# "initializationVector": "vector-value"
|
352
|
+
# }
|
353
|
+
# }
|
354
|
+
|
355
|
+
# Access top-level keys with dig
|
356
|
+
feed_document_id = document_response.dig("feedDocumentId")
|
357
|
+
upload_url = document_response.dig("url")
|
358
|
+
|
359
|
+
# Access nested keys - returns nil if any key in the path is missing
|
360
|
+
encryption_key = document_response.dig("encryptionDetails", "key")
|
361
|
+
|
362
|
+
# Step 2: Upload feed content to the input document
|
363
|
+
feed_content = File.read("inventory_update.xml")
|
364
|
+
api.upload_feed_document(upload_url, feed_content, "text/xml; charset=UTF-8")
|
365
|
+
|
366
|
+
# Step 3: Create feed referencing the input document
|
367
|
+
feed_response = api.create_feed(
|
368
|
+
feedType: "POST_INVENTORY_AVAILABILITY_DATA",
|
369
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
370
|
+
inputFeedDocumentId: feed_document_id
|
371
|
+
)
|
372
|
+
feed_id = feed_response.dig("feedId")
|
373
|
+
|
374
|
+
# Step 4: Wait for feed to complete (polling or SQS notification)
|
375
|
+
# Poll until status is "DONE", "FATAL", or "CANCELLED"
|
376
|
+
loop do
|
377
|
+
feed_status = api.get_feed(feed_id)
|
378
|
+
status = feed_status.dig("processingStatus")
|
379
|
+
break if ["DONE", "FATAL", "CANCELLED"].include?(status)
|
380
|
+
sleep 30 # Wait 30 seconds before checking again
|
381
|
+
end
|
382
|
+
|
383
|
+
# Step 5: Get feed document (result document with processing results)
|
384
|
+
result_document_id = feed_status.dig("resultFeedDocumentId")
|
385
|
+
result_document = api.get_feed_document(result_document_id) if result_document_id
|
386
|
+
|
387
|
+
# Step 6: Download results to see processing outcome
|
388
|
+
if result_document
|
389
|
+
download_url = result_document.dig("url")
|
390
|
+
response = HTTP.get(download_url)
|
391
|
+
content = if result_document.dig("compressionAlgorithm") == "GZIP"
|
392
|
+
Zlib::GzipReader.new(response).read
|
393
|
+
else
|
394
|
+
response.to_s
|
395
|
+
end
|
396
|
+
# Parse content to check for errors/success
|
397
|
+
end
|
398
|
+
|
399
|
+
# JSON feed example
|
400
|
+
json_document = api.create_feed_document(
|
401
|
+
{ "contentType" => "application/json; charset=UTF-8" }
|
402
|
+
)
|
403
|
+
json_feed_content = JSON.generate({
|
404
|
+
"header": {
|
405
|
+
"sellerId": "SELLER_ID",
|
406
|
+
"version": "2.0",
|
407
|
+
"issueLocale": "en_US"
|
408
|
+
},
|
409
|
+
"messages": [
|
410
|
+
{
|
411
|
+
"messageId": 1,
|
412
|
+
"sku": "SKU123",
|
413
|
+
"operationType": "UPDATE",
|
414
|
+
"productType": "PRODUCT",
|
415
|
+
"attributes": {
|
416
|
+
# Your product attributes here
|
417
|
+
}
|
418
|
+
}
|
419
|
+
]
|
420
|
+
})
|
421
|
+
api.upload_feed_document(json_document.dig("url"), json_feed_content, "application/json; charset=UTF-8")
|
276
422
|
```
|
277
423
|
|
278
|
-
####
|
424
|
+
#### Communication and Customer Management APIs
|
425
|
+
|
426
|
+
- **Customer Feedback API (2024-06-01)**: Analyze customer reviews and returns data at item and browse node levels
|
427
|
+
- **Notifications API (v1)**: Subscribe to notifications for events like order updates
|
428
|
+
- **Messaging API (v1)**: Send messages to customers
|
429
|
+
- **Solicitations API (v1)**: Request customer reviews
|
430
|
+
|
431
|
+
```ruby
|
432
|
+
# Customer Feedback API example
|
433
|
+
api = Peddler.customer_feedback_2024_06_01(aws_region, access_token)
|
434
|
+
|
435
|
+
# Get item review topics (most positive and negative)
|
436
|
+
review_topics = api.get_item_review_topics(
|
437
|
+
"B08N5WRWNW", # ASIN
|
438
|
+
Marketplace.id("US"),
|
439
|
+
"frequency" # Sort by frequency
|
440
|
+
)
|
279
441
|
|
280
|
-
|
442
|
+
# Get item review trends for past 6 months
|
443
|
+
review_trends = api.get_item_review_trends(
|
444
|
+
"B08N5WRWNW",
|
445
|
+
Marketplace.id("US")
|
446
|
+
)
|
447
|
+
|
448
|
+
# Get browse node return topics
|
449
|
+
return_topics = api.get_browse_node_return_topics(
|
450
|
+
"123456789", # Browse node ID
|
451
|
+
Marketplace.id("US")
|
452
|
+
)
|
453
|
+
```
|
281
454
|
|
282
455
|
```ruby
|
283
|
-
api = Peddler.
|
456
|
+
api = Peddler.notifications(aws_region, access_token)
|
284
457
|
# Create destination
|
285
458
|
destination = api.create_destination(
|
286
459
|
name: "MyEventQueue",
|
@@ -288,7 +461,7 @@ destination = api.create_destination(
|
|
288
461
|
sqs: { arn: "arn:aws:sqs:us-east-1:123456789012:MyQueue" }
|
289
462
|
}
|
290
463
|
)
|
291
|
-
destination_id = destination.
|
464
|
+
destination_id = destination.dig("payload", "destinationId")
|
292
465
|
|
293
466
|
# Create subscription
|
294
467
|
api.create_subscription(
|
@@ -296,6 +469,14 @@ api.create_subscription(
|
|
296
469
|
destinationId: destination_id,
|
297
470
|
payloadVersion: "1"
|
298
471
|
)
|
472
|
+
|
473
|
+
# For sandbox testing (requires grantless token)
|
474
|
+
sandbox_api = Peddler.notifications(aws_region, grantless_access_token).sandbox
|
475
|
+
# Get all destinations
|
476
|
+
destinations = sandbox_api.get_destinations
|
477
|
+
|
478
|
+
# Get specific subscription
|
479
|
+
subscription = sandbox_api.get_subscription("LISTINGS_ITEM_ISSUES_CHANGE")
|
299
480
|
```
|
300
481
|
|
301
482
|
#### Vendor APIs
|
@@ -303,37 +484,207 @@ api.create_subscription(
|
|
303
484
|
APIs for vendors selling to Amazon:
|
304
485
|
|
305
486
|
- **Vendor Orders API (v1)**: Retrieve purchase orders
|
306
|
-
- **Vendor Direct Fulfillment
|
487
|
+
- **Vendor Direct Fulfillment Orders API (2021-12-28, v1)**: Manage direct fulfillment orders
|
488
|
+
- **Vendor Direct Fulfillment Shipping API (2021-12-28, v1)**: Manage shipping for direct fulfillment
|
489
|
+
- **Vendor Direct Fulfillment Payments API (v1)**: Process payments for direct fulfillment
|
490
|
+
- **Vendor Direct Fulfillment Inventory API (v1)**: Manage inventory for direct fulfillment
|
491
|
+
- **Vendor Direct Fulfillment Transactions API (2021-12-28, v1)**: Track transaction status
|
492
|
+
- **Vendor Direct Fulfillment Sandbox Test Data API (2021-10-28)**: Generate test data in sandbox
|
307
493
|
- **Vendor Shipments API (v1)**: Track vendor shipments
|
308
494
|
- **Vendor Invoices API (v1)**: Submit and track invoices
|
495
|
+
- **Vendor Transaction Status API (v1)**: Check transaction status
|
309
496
|
|
310
497
|
```ruby
|
311
|
-
api = Peddler.
|
498
|
+
api = Peddler.vendor_orders(aws_region, access_token)
|
312
499
|
orders = api.get_purchase_orders(
|
313
500
|
limit: 10,
|
314
501
|
createdAfter: "2023-01-01T00:00:00Z"
|
315
502
|
).parse
|
316
503
|
```
|
317
504
|
|
318
|
-
####
|
505
|
+
#### Authorization and Account Management APIs
|
319
506
|
|
320
|
-
- **
|
321
|
-
- **Authorization API (2023-11-30)**: Manage app authorization
|
322
|
-
- **Messaging API (v1)**: Send messages to customers
|
323
|
-
- **Product Fees API (v0)**: Retrieve fee estimates for products
|
324
|
-
- **Product Pricing API (2022-05-01, v0)**: Get pricing information
|
325
|
-
- **Sellers API (v1)**: Get seller account information and marketplace participation
|
326
|
-
- **Shipping APIs (v1, v2)**: Create shipments and purchase shipping labels
|
327
|
-
- **Solicitations API (v1)**: Request customer reviews
|
507
|
+
- **Application Management API (2023-11-30)**: Manage application authorization
|
328
508
|
- **Tokens API (2021-03-01)**: Generate restricted data tokens for accessing PII
|
329
|
-
- **
|
509
|
+
- **Sellers API (v1)**: Get seller account information and marketplace participation
|
510
|
+
- **Services API (v1)**: Manage seller services and subscriptions
|
511
|
+
- **Seller Wallet API (2024-03-01)**: Manage seller financial accounts
|
512
|
+
- **Application Integrations API (2024-04-01)**: Manage app integrations
|
513
|
+
- **Vehicles API (2024-11-01)**: Manage vehicle data for automotive products
|
514
|
+
|
515
|
+
### Additional API Examples
|
516
|
+
|
517
|
+
#### Product Pricing API
|
518
|
+
|
519
|
+
```ruby
|
520
|
+
# Using Product Pricing v0
|
521
|
+
api = Peddler.product_pricing_v0(aws_region, access_token)
|
522
|
+
|
523
|
+
# Get pricing information for an ASIN
|
524
|
+
pricing = api.get_pricing(
|
525
|
+
Marketplace.id("US"),
|
526
|
+
"Asin",
|
527
|
+
asins: ["B08N5WRWNW"]
|
528
|
+
)
|
529
|
+
|
530
|
+
# Get competitive pricing for an ASIN
|
531
|
+
competitive = api.get_competitive_pricing(
|
532
|
+
Marketplace.id("US"),
|
533
|
+
"Asin",
|
534
|
+
asins: ["B08N5WRWNW"]
|
535
|
+
)
|
536
|
+
|
537
|
+
# Get offers for a specific item
|
538
|
+
offers = api.get_item_offers(
|
539
|
+
Marketplace.id("US"),
|
540
|
+
"New",
|
541
|
+
"B08N5WRWNW"
|
542
|
+
)
|
330
543
|
|
331
|
-
|
544
|
+
# Batch request for multiple items (2022-05-01 API)
|
545
|
+
api = Peddler.product_pricing_2022_05_01(aws_region, access_token)
|
546
|
+
batch_request = {
|
547
|
+
requests: [
|
548
|
+
{
|
549
|
+
uri: "/products/pricing/2022-05-01/items/competitiveSummary",
|
550
|
+
method: "GET",
|
551
|
+
asin: "B08N5WRWNW",
|
552
|
+
marketplaceId: Marketplace.id("US"),
|
553
|
+
includedData: ["featuredBuyingOptions", "referencePrices", "lowestPricedOffers"]
|
554
|
+
},
|
555
|
+
# Additional items...
|
556
|
+
]
|
557
|
+
}
|
558
|
+
results = api.get_competitive_summary(batch_request)
|
559
|
+
```
|
560
|
+
|
561
|
+
#### Listings Items API
|
562
|
+
|
563
|
+
```ruby
|
564
|
+
api = Peddler.listings_items(aws_region, access_token)
|
332
565
|
|
333
|
-
|
566
|
+
# Create or update a listing
|
567
|
+
listing_result = api.put_listings_item(
|
568
|
+
"SELLER_ID",
|
569
|
+
"SKU123",
|
570
|
+
Marketplace.id("US"),
|
571
|
+
{
|
572
|
+
productType: "PRODUCT",
|
573
|
+
requirements: "LISTING_OFFER_ONLY",
|
574
|
+
attributes: {
|
575
|
+
merchant_suggested_asin: [{
|
576
|
+
value: "B08N5WRWNW",
|
577
|
+
marketplace_id: Marketplace.id("US")
|
578
|
+
}],
|
579
|
+
condition_type: [{
|
580
|
+
value: "new_new",
|
581
|
+
marketplace_id: Marketplace.id("US")
|
582
|
+
}],
|
583
|
+
# Additional attributes...
|
584
|
+
}
|
585
|
+
}
|
586
|
+
)
|
587
|
+
|
588
|
+
# Update specific listing elements with JSON Patch
|
589
|
+
patch_result = api.patch_listings_item(
|
590
|
+
"SELLER_ID",
|
591
|
+
"SKU123",
|
592
|
+
Marketplace.id("US"),
|
593
|
+
{
|
594
|
+
productType: "PRODUCT",
|
595
|
+
patches: [
|
596
|
+
{
|
597
|
+
op: "replace",
|
598
|
+
path: "/attributes/purchasable_offer",
|
599
|
+
value: [{
|
600
|
+
currency: "USD",
|
601
|
+
our_price: [{
|
602
|
+
schedule: [{
|
603
|
+
value_with_tax: 39.99
|
604
|
+
}]
|
605
|
+
}]
|
606
|
+
}]
|
607
|
+
}
|
608
|
+
]
|
609
|
+
}
|
610
|
+
)
|
611
|
+
|
612
|
+
# Get listing details
|
613
|
+
listing = api.get_listings_item(
|
614
|
+
"SELLER_ID",
|
615
|
+
"SKU123",
|
616
|
+
Marketplace.id("US"),
|
617
|
+
included_data: "attributes,issues"
|
618
|
+
)
|
619
|
+
|
620
|
+
# Delete a listing
|
621
|
+
api.delete_listings_item("SELLER_ID", "SKU123", Marketplace.id("US"))
|
622
|
+
```
|
623
|
+
|
624
|
+
#### Listings Restrictions API
|
625
|
+
|
626
|
+
```ruby
|
627
|
+
api = Peddler.listings_restrictions(aws_region, access_token)
|
628
|
+
|
629
|
+
# Check restrictions for an ASIN
|
630
|
+
restrictions = api.get_listings_restrictions(
|
631
|
+
"B08N5WRWNW",
|
632
|
+
"SELLER_ID",
|
633
|
+
Marketplace.id("US"),
|
634
|
+
condition_type: "new_new"
|
635
|
+
)
|
636
|
+
```
|
637
|
+
|
638
|
+
#### Product Type Definitions API
|
639
|
+
|
640
|
+
```ruby
|
641
|
+
api = Peddler.product_type_definitions(aws_region, access_token)
|
642
|
+
|
643
|
+
# Get schema for a product type
|
644
|
+
definition = api.get_definitions_product_type(
|
645
|
+
"PRODUCT",
|
646
|
+
Marketplace.id("US"),
|
647
|
+
requirements: "LISTING_OFFER_ONLY"
|
648
|
+
)
|
649
|
+
|
650
|
+
# Download the JSON schema
|
651
|
+
schema_url = definition.dig("schema", "link", "resource")
|
652
|
+
json_schema = HTTP.get(schema_url).parse(:json)
|
653
|
+
```
|
654
|
+
|
655
|
+
#### Reports API
|
656
|
+
|
657
|
+
```ruby
|
658
|
+
api = Peddler.reports(aws_region, access_token)
|
659
|
+
|
660
|
+
# Request a report
|
661
|
+
report_response = api.create_report({
|
662
|
+
"reportType" => "GET_MERCHANTS_LISTINGS_FYP_REPORT",
|
663
|
+
"marketplaceIds" => Marketplace.ids("US")
|
664
|
+
})
|
665
|
+
report_id = report_response.dig("reportId")
|
666
|
+
|
667
|
+
# Get report status
|
668
|
+
report = api.get_report(report_id)
|
669
|
+
|
670
|
+
# Get all reports of a specific type
|
671
|
+
reports = api.get_reports(report_types: ["GET_MERCHANTS_LISTINGS_FYP_REPORT"])
|
672
|
+
|
673
|
+
# Download a report document (using convenience helper)
|
674
|
+
response = api.download_report_document("DOCUMENT_ID")
|
675
|
+
# Process the downloaded report content from response.body...
|
676
|
+
```
|
677
|
+
|
678
|
+
#### Sellers API
|
679
|
+
|
680
|
+
```ruby
|
681
|
+
api = Peddler.sellers(aws_region, access_token)
|
682
|
+
|
683
|
+
# Get marketplace participations
|
684
|
+
participations = api.get_marketplace_participations
|
685
|
+
```
|
334
686
|
|
335
|
-
|
336
|
-
- [ ] Review and consider applying [these patches][patches]
|
687
|
+
For a complete list of available APIs and their detailed documentation, refer to the [API models repository](https://github.com/amzn/selling-partner-api-models).
|
337
688
|
|
338
689
|
[build]: https://github.com/hakanensari/peddler/actions
|
339
690
|
[docs-overview]: https://developer.amazonservices.com/sp-api-docs/overview
|
@@ -345,4 +696,3 @@ For a complete list of available APIs, refer to the [API models repository](http
|
|
345
696
|
[authorization]: https://developer-docs.amazon.com/sp-api/docs/authorizing-selling-partner-api-applications
|
346
697
|
[rate-limits]: https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits
|
347
698
|
[httprb]: https://github.com/httprb/http
|
348
|
-
[patches]: https://github.com/bizon/selling-partner-api-sdk/tree/master/codegen/patches
|