peddler 3.0.0.beta1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +96 -106
  3. data/lib/peddler/api/amazon_warehousing_and_distribution_2024_05_09.rb +34 -22
  4. data/lib/peddler/api/aplus_content_2020_11_01.rb +86 -48
  5. data/lib/peddler/api/application_integrations_2024_04_01.rb +56 -0
  6. data/lib/peddler/api/application_management_2023_11_30.rb +12 -2
  7. data/lib/peddler/api/catalog_items_2020_12_01.rb +31 -20
  8. data/lib/peddler/api/catalog_items_2022_04_01.rb +35 -25
  9. data/lib/peddler/api/catalog_items_v0.rb +39 -26
  10. data/lib/peddler/api/data_kiosk_2023_11_15.rb +41 -25
  11. data/lib/peddler/api/easy_ship_2022_03_23.rb +62 -43
  12. data/lib/peddler/api/fba_inbound_eligibility_v1.rb +13 -5
  13. data/lib/peddler/api/fba_inventory_v1.rb +40 -24
  14. data/lib/peddler/api/feeds_2021_06_30.rb +43 -25
  15. data/lib/peddler/api/finances_2024_06_19.rb +50 -0
  16. data/lib/peddler/api/finances_v0.rb +86 -59
  17. data/lib/peddler/api/fulfillment_inbound_2024_03_20.rb +304 -205
  18. data/lib/peddler/api/fulfillment_inbound_v0.rb +112 -74
  19. data/lib/peddler/api/fulfillment_outbound_2020_07_01.rb +90 -53
  20. data/lib/peddler/api/invoices_2024_06_19.rb +180 -0
  21. data/lib/peddler/api/listings_items_2020_09_01.rb +44 -33
  22. data/lib/peddler/api/listings_items_2021_08_01.rb +76 -60
  23. data/lib/peddler/api/listings_restrictions_2021_08_01.rb +19 -9
  24. data/lib/peddler/api/merchant_fulfillment_v0.rb +31 -15
  25. data/lib/peddler/api/messaging_v1.rb +93 -61
  26. data/lib/peddler/api/notifications_v1.rb +54 -23
  27. data/lib/peddler/api/orders_v0.rb +87 -72
  28. data/lib/peddler/api/product_fees_v0.rb +39 -31
  29. data/lib/peddler/api/product_pricing_2022_05_01.rb +17 -6
  30. data/lib/peddler/api/product_pricing_v0.rb +63 -45
  31. data/lib/peddler/api/product_type_definitions_2020_09_01.rb +29 -18
  32. data/lib/peddler/api/replenishment_2022_11_07.rb +21 -9
  33. data/lib/peddler/api/reports_2021_06_30.rb +60 -36
  34. data/lib/peddler/api/sales_v1.rb +20 -12
  35. data/lib/peddler/api/sellers_v1.rb +16 -4
  36. data/lib/peddler/api/services_v1.rb +138 -98
  37. data/lib/peddler/api/shipment_invoicing_v0.rb +25 -12
  38. data/lib/peddler/api/shipping_v1.rb +54 -29
  39. data/lib/peddler/api/shipping_v2.rb +132 -80
  40. data/lib/peddler/api/solicitations_v1.rb +18 -8
  41. data/lib/peddler/api/supply_sources_2020_07_01.rb +33 -15
  42. data/lib/peddler/api/tokens_2021_03_01.rb +13 -5
  43. data/lib/peddler/api/uploads_2020_11_01.rb +16 -6
  44. data/lib/peddler/api/vendor_direct_fulfillment_inventory_v1.rb +12 -4
  45. data/lib/peddler/api/vendor_direct_fulfillment_orders_2021_12_28.rb +29 -17
  46. data/lib/peddler/api/vendor_direct_fulfillment_orders_v1.rb +29 -17
  47. data/lib/peddler/api/vendor_direct_fulfillment_payments_v1.rb +11 -3
  48. data/lib/peddler/api/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +14 -4
  49. data/lib/peddler/api/vendor_direct_fulfillment_shipping_2021_12_28.rb +74 -48
  50. data/lib/peddler/api/vendor_direct_fulfillment_shipping_v1.rb +74 -50
  51. data/lib/peddler/api/vendor_direct_fulfillment_transactions_2021_12_28.rb +11 -3
  52. data/lib/peddler/api/vendor_direct_fulfillment_transactions_v1.rb +11 -3
  53. data/lib/peddler/api/vendor_invoices_v1.rb +11 -3
  54. data/lib/peddler/api/vendor_orders_v1.rb +54 -43
  55. data/lib/peddler/api/vendor_shipments_v1.rb +63 -51
  56. data/lib/peddler/api/vendor_transaction_status_v1.rb +12 -3
  57. data/lib/peddler/api.rb +41 -18
  58. data/lib/peddler/endpoint.rb +51 -0
  59. data/lib/peddler/error.rb +1 -0
  60. data/lib/peddler/marketplace.rb +49 -0
  61. data/lib/peddler/token.rb +70 -0
  62. data/lib/peddler/version.rb +1 -1
  63. data/lib/peddler.rb +56 -52
  64. metadata +10 -6
  65. data/lib/peddler/access_token.rb +0 -76
  66. data/lib/peddler/region.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f132e3d74dc1f70f5f0d84f84cc75e6d4e9184bd2ed4162e2e805a766341afed
4
- data.tar.gz: 65c57dc08f0d1e1b23f87969ec2657d7592ea4590c65d3c18b7e9c9ac612ed71
3
+ metadata.gz: 18b989739aa0f7ab2781e4f2f921b61a6f188ffc72145eb9308e47d3f5072e96
4
+ data.tar.gz: 0ea9798e14b2e7474fef0c8b492d43e90d427fee962d4f837fc46722750733b8
5
5
  SHA512:
6
- metadata.gz: cc5e82f24bd72cebd6d226e713d22e792944e043489da3a7f79245fd5242f1430cef84201643e9ebd5a25d9b5a10c9bbf5ae88e70f27a4d52a7b077482f9760a
7
- data.tar.gz: 80a16515b74499a28513058b41eab6a912bcb21249d7748cedd74db9efd7e3ccc2316e896f78b9406c2e1f7d078b667ad73a62a980054cd0982135a9b219fd0f
6
+ metadata.gz: 9acfcab4a74ef4842c1cb28e94b1a57591caba5080e07a6db34d8f20f69b0d215efdcfb98761fefeaf840cb4a0c91cc574807651c8beb309dbfc91ad66502b05
7
+ data.tar.gz: 281d96aa87b0ea0c480282049124c8ed3037e4a31ef8251b7a6cc3e8c17acbb53e8253a41f248a6e3a95eea7c6d3363d740e0d23dffe2b6e1caaf82bbbdbea09
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  **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.
8
8
 
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 on Amazon][view-credentials]. You'll use these to access data for your own seller account or retrieve data on behalf of others.
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
  ![Peddler](https://github.com/hakanensari/peddler/blob/main/images/peddler.jpg?raw=true)
12
12
 
@@ -39,53 +39,65 @@ Require the library.
39
39
  require "peddler"
40
40
  ```
41
41
 
42
- ### Authentication
42
+ ### Authorization
43
43
 
44
- A seller or vendor will [provide a refresh token][authorization] to access their data on Amazon. You'll use this to generate temporary access tokens to authenticate individual API requests. Here’s how you can request one in Peddler.
44
+ A seller or vendor [provides you a refresh token][authorization] to access their data on Amazon.
45
45
 
46
46
  ```ruby
47
- access_token = Peddler::AccessToken.request(
47
+ refresh_token = Peddled::Token.request(
48
+ code: "<AUTHORIZATION_CODE>"
49
+ ).parse["refresh_token"]
50
+ ```
51
+
52
+ You use this to generate a temporary access token to authenticate individual API requests.
53
+
54
+ ```ruby
55
+ access_token = Peddler::Token.request(
48
56
  refresh_token: "<REFRESH_TOKEN>",
49
- )
57
+ ).parse["access_token"]
50
58
  ```
51
59
 
52
- You can also request a token for grantless operations.
60
+ Similarly, you can request a token for grantless operations.
53
61
 
54
62
  ```ruby
55
- access_token = Peddler::AccessToken.request(
63
+ access_token = Peddler::Token.request(
56
64
  scope: "sellingpartnerapi::notifications",
57
- )
65
+ ).parse["access_token"]
58
66
  ```
59
67
 
60
- Access tokens are valid for one hour. To optimize performance, cache the token and reuse it across calls instead of generating a new one each time.
61
-
62
- If you haven’t set your LWA credentials as environment variables, you can pass them directly when requesting an access token:
68
+ If you haven’t set your LWA credentials as environment variables, pass them directly when requesting the token.
63
69
 
64
70
  ```ruby
65
- access_token = Peddler::AccessToken.request(
71
+ access_token = Peddler::Token.request(
66
72
  client_id: "<YOUR_CLIENT_ID>",
67
73
  client_secret: "<YOUR_CLIENT_SECRET>",
68
74
  refresh_token: "<REFRESH_TOKEN>",
69
- )
75
+ ).parse["access_token"]
70
76
  ```
71
77
 
72
- ### Throttling
78
+ Access tokens are valid for one hour. To optimize performance, cache the token and reuse across calls.
73
79
 
74
- Amazon’s Selling Partner API (SP-API) imposes standard rate limits on most operations. Peddler respects these limits and automatically backs off when throttled to ensure compliance with Amazon’s policies.
75
-
76
- **Note:** This functionality requires version 6 of the underlying [HTTP library][httprb]. As of writing, this is not released yet. To use rate limiting, point to the main branch of their GitHub repo:
80
+ In Rails, if you're storing a refresh token in a model representing a selling partner, implement a method there to retrieve and cache access tokens:
77
81
 
78
82
  ```ruby
79
- gem "http", github: "httprb/http"
83
+ class Seller
84
+ "..."
85
+
86
+ def access_token
87
+ Rails.cache.fetch("#{cache_key}/access_key", expires_in: 1.hour) do
88
+ Peddler::Token.request(
89
+ refresh_token:,
90
+ ).parse["access_token"]
91
+ end
92
+ end
93
+ end
80
94
  ```
81
95
 
82
- If you have custom rate limits (e.g., Amazon has granted you higher quotas), you can override the standard rate limit using the rate_limit method.
96
+ ### Rate limiting
83
97
 
84
- ```ruby
85
- @api.rate_limit(5).get_item_offers_batch(...)
86
- ```
98
+ Amazon’s Selling Partner API (SP-API) imposes [rate limits][rate-limits] on most operations. Peddler respects these limits and automatically backs off when throttled. To override the default rate limit, pass a `:rate_limit` argument when running an operation.
87
99
 
88
- This sets a custom rate limit of 5 requests per second for the requested operation.
100
+ **Note:** This functionality requires version 6 of the underlying [HTTP library][httprb]. As of writing, this is not released yet. To use rate limiting, point to their main branch on GitHub.
89
101
 
90
102
  ### The APIs
91
103
 
@@ -95,11 +107,9 @@ Peddler provides a class for each API version under an eponymous namespace. Belo
95
107
 
96
108
  Provides programmatic access to Amazon's catalog data, such as item titles, descriptions, and other product details.
97
109
 
98
- **Example:**
99
-
100
110
  ```ruby
101
- client = Peddler::API::CatalogItems20220401.new("<AWS_REGION>", "<ACCESS_TOKEN>")
102
- response = client.get_catalog_item(
111
+ api = Peddler.catalog_items_2022_04_01(aws_region, access_token)
112
+ response = api.get_catalog_item(
103
113
  marketplaceIds: ["ATVPDKIKX0DER"],
104
114
  asin: "B08N5WRWNW"
105
115
  )
@@ -110,27 +120,24 @@ items = response.parse.dig("items")
110
120
 
111
121
  Allows you to retrieve order information, including order details, buyer information, and order items.
112
122
 
113
- **Example:**
114
-
115
123
  ```ruby
116
- client = Peddler::API::OrdersV0.new("<AWS_REGION>", "<ACCESS_TOKEN>")
117
- response = client.get_orders(
124
+ api = Peddler.orders_v0(aws_region, access_token)
125
+ response = api.get_orders(
118
126
  marketplaceIds: ["ATVPDKIKX0DER"],
119
127
  createdAfter: "2023-01-01T00:00:00Z"
120
128
  )
121
- orders = response.parse.dig("orders")
129
+ response.parse.dig("orders")
122
130
  ```
123
131
 
124
132
  #### Feeds API (2021-06-30)
125
133
 
126
134
  Enables you to upload data to Amazon for updating listings, prices, inventory, and more.
127
135
 
128
- **Example:**
129
-
130
136
  ```ruby
131
- client = Peddler::API::Feeds20210630.new("<AWS_REGION>", "<ACCESS_TOKEN>")
137
+ api = Peddler.feeds_2021_06_30(aws_region, access_token)
138
+
132
139
  # Create a feed document to get an upload URL
133
- response = client.create_feed_document(
140
+ response = api.create_feed_document(
134
141
  contentType: "text/xml; charset=UTF-8"
135
142
  )
136
143
  feed_document_id = response.parse["feedDocumentId"]
@@ -138,41 +145,37 @@ upload_url = response.parse["url"]
138
145
 
139
146
  # Upload the feed content to the provided URL
140
147
  feed_content = File.read("inventory_update.xml")
141
- client.upload_feed_document(upload_url, feed_content)
148
+ api.upload_feed_document(upload_url, feed_content)
142
149
 
143
150
  # Create the feed
144
- response = client.create_feed(
151
+ response = api.create_feed(
145
152
  feedType: "POST_INVENTORY_AVAILABILITY_DATA",
146
153
  marketplaceIds: ["ATVPDKIKX0DER"],
147
154
  inputFeedDocumentId: feed_document_id
148
155
  )
149
- feed_id = response.parse["feedId"]
156
+ response.parse["feedId"]
150
157
  ```
151
158
 
152
159
  #### Reports API (2021-06-30)
153
160
 
154
161
  Allows you to request and download various reports, such as order and inventory reports.
155
162
 
156
- **Example:**
157
-
158
163
  ```ruby
159
- client = Peddler::API::Reports20210630.new("<AWS_REGION>", "<ACCESS_TOKEN>")
160
- response = client.create_report(
164
+ api = Peddler.reports_2021_06_30(aws_region, access_token)
165
+ response = api.create_report(
161
166
  reportType: "GET_FLAT_FILE_OPEN_LISTINGS_DATA",
162
167
  marketplaceIds: ["ATVPDKIKX0DER"]
163
168
  )
164
- report_id = response.parse["reportId"]
169
+ response.parse["reportId"]
165
170
  ```
166
171
 
167
172
  #### Listings Items API (2021-08-01)
168
173
 
169
174
  Enables you to manage your product listings on Amazon, including creating, updating, and deleting listings.
170
175
 
171
- **Example:**
172
-
173
176
  ```ruby
174
- client = Peddler::API::ListingsItems20210801.new("<AWS_REGION>", "<ACCESS_TOKEN>")
175
- response = client.put_listings_item(
177
+ api = Peddler.listings_items_2021_08_01(aws_region, access_token)
178
+ response = api.put_listings_item(
176
179
  "<SELLER_ID>",
177
180
  "SKU123",
178
181
  "ATVPDKIKX0DER",
@@ -187,19 +190,17 @@ response = client.put_listings_item(
187
190
  }
188
191
  }
189
192
  )
190
- result = response.parse
193
+ response.parse
191
194
  ```
192
195
 
193
196
  #### Notifications API (v1)
194
197
 
195
198
  Allows you to subscribe to notifications for specific events like order status updates or feed processing statuses.
196
199
 
197
- **Example:**
198
-
199
200
  ```ruby
200
- client = Peddler::API::NotificationsV1.new("<AWS_REGION>", "<ACCESS_TOKEN>")
201
+ api = Peddler.notifications_v1(aws_region, access_token)
201
202
  # Create a destination
202
- response = client.create_destination(
203
+ response = api.create_destination(
203
204
  name: "MySQSQueue",
204
205
  resourceSpecification: {
205
206
  sqs: {
@@ -210,7 +211,7 @@ response = client.create_destination(
210
211
  destination_id = response.parse["destinationId"]
211
212
 
212
213
  # Create a subscription
213
- response = client.create_subscription(
214
+ response = api.create_subscription(
214
215
  notificationType: "ANY_OFFER_CHANGED",
215
216
  destinationId: destination_id
216
217
  )
@@ -221,11 +222,9 @@ subscription = response.parse
221
222
 
222
223
  Provides information about fees that may be charged for selling products on Amazon.
223
224
 
224
- **Example:**
225
-
226
225
  ```ruby
227
- client = Peddler::API::ProductFeesV0.new("<AWS_REGION>", "<ACCESS_TOKEN>")
228
- response = client.get_my_fees_estimate_for_sku(
226
+ api = Peddler.product_fees_v0(aws_region, access_token)
227
+ response = api.get_my_fees_estimate_for_sku(
229
228
  sellerId: "<YOUR_SELLER_ID>",
230
229
  sku: "SKU123",
231
230
  body: {
@@ -248,11 +247,9 @@ fees_estimate = response.parse
248
247
 
249
248
  Allows you to create and manage fulfillment orders using Amazon's fulfillment network.
250
249
 
251
- **Example:**
252
-
253
250
  ```ruby
254
- client = Peddler::API::FulfillmentOutbound20200701.new("<AWS_REGION>", "<ACCESS_TOKEN>")
255
- response = client.create_fulfillment_order(
251
+ api = Peddler.fulfillment_outbound_2020_07_01(aws_region, access_token)
252
+ response = api.create_fulfillment_order(
256
253
  body: {
257
254
  sellerFulfillmentOrderId: "ORDER123",
258
255
  displayableOrderId: "ORDER123",
@@ -276,18 +273,16 @@ response = client.create_fulfillment_order(
276
273
  ]
277
274
  }
278
275
  )
279
- result = response.parse
276
+ response.parse
280
277
  ```
281
278
 
282
279
  #### Merchant Fulfillment API (v0)
283
280
 
284
281
  Allows you to create shipping labels for orders using Amazon's negotiated shipping rates.
285
282
 
286
- **Example:**
287
-
288
283
  ```ruby
289
- client = Peddler::API::MerchantFulfillmentV0.new("<AWS_REGION>", "<ACCESS_TOKEN>")
290
- response = client.get_eligible_shipping_services(
284
+ api = Peddler.merchant_fulfillment_v0(aws_region, access_token)
285
+ response = api.get_eligible_shipping_services(
291
286
  body: {
292
287
  shipmentRequestDetails: {
293
288
  amazonOrderId: "ORDER123",
@@ -329,11 +324,9 @@ shipping_services = response.parse["shippingServiceList"]
329
324
 
330
325
  Allows vendors to retrieve purchase orders and order details from Amazon.
331
326
 
332
- **Example:**
333
-
334
327
  ```ruby
335
- client = Peddler::API::VendorOrders20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
336
- response = client.get_purchase_orders(
328
+ api = Peddler.vendor_orders_2021_12_28(aws_region, access_token)
329
+ response = api.get_purchase_orders(
337
330
  shipToPartyId: "<PARTY_ID>",
338
331
  limit: 10,
339
332
  createdAfter: "2023-01-01T00:00:00Z"
@@ -345,40 +338,36 @@ purchase_orders = response.parse["purchaseOrders"]
345
338
 
346
339
  Enables vendors to manage shipping labels and shipping information for direct fulfillment orders.
347
340
 
348
- **Example:**
349
341
 
350
342
  ```ruby
351
- client = Peddler::API::VendorDirectFulfillmentShipping20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
352
- response = client.get_packing_slip(
343
+ api = Peddler.vendor_direct_fulfillment_shipping_2021_12_28(aws_region, access_token)
344
+ response = api.get_packing_slip(
353
345
  purchaseOrderNumber: "PO123456789"
354
346
  )
355
- packing_slip = response.parse
347
+ response.parse
356
348
  ```
357
349
 
358
350
  #### Vendor Direct Fulfillment Orders API (2021-12-28)
359
351
 
360
352
  Allows vendors to receive orders for direct fulfillment and provide shipment confirmations.
361
353
 
362
- **Example:**
363
354
 
364
355
  ```ruby
365
- client = Peddler::API::VendorDirectFulfillmentOrders20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
366
- response = client.get_orders(
356
+ api = Peddler.vendor_direct_fulfillment_orders_2021_12_28(aws_region, access_token)
357
+ response = api.get_orders(
367
358
  createdAfter: "2023-01-01T00:00:00Z",
368
359
  limit: 10
369
360
  )
370
- orders = response.parse["orders"]
361
+ response.parse["orders"]
371
362
  ```
372
363
 
373
364
  #### Vendor Direct Fulfillment Inventory API (2021-12-28)
374
365
 
375
366
  Enables vendors to update inventory levels for direct fulfillment items.
376
367
 
377
- **Example:**
378
-
379
368
  ```ruby
380
- client = Peddler::API::VendorDirectFulfillmentInventory20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
381
- response = client.submit_inventory_update(
369
+ api = Peddler.vendor_direct_fulfillment_inventory_2021_12_28(aws_region, access_token)
370
+ response = api.submit_inventory_update(
382
371
  body: {
383
372
  inventory: [
384
373
  {
@@ -399,18 +388,16 @@ response = client.submit_inventory_update(
399
388
  ]
400
389
  }
401
390
  )
402
- result = response.parse
391
+ response.parse
403
392
  ```
404
393
 
405
394
  #### Shipping API (v2)
406
395
 
407
396
  Provides functionalities for purchasing shipping labels and tracking shipments.
408
397
 
409
- **Example:**
410
-
411
398
  ```ruby
412
- client = Peddler::API::ShippingV2.new("<AWS_REGION>", "<ACCESS_TOKEN>")
413
- response = client.purchase_shipment(
399
+ api = Peddler.shipping_v2(aws_region, access_token)
400
+ response = api.purchase_shipment(
414
401
  body: {
415
402
  clientReferenceId: "CLIENT_REF_123",
416
403
  shipTo: {
@@ -446,18 +433,16 @@ response = client.purchase_shipment(
446
433
  serviceType: "Standard"
447
434
  }
448
435
  )
449
- shipment = response.parse
436
+ response.parse
450
437
  ```
451
438
 
452
439
  #### Token API (2021-03-01)
453
440
 
454
441
  Allows you to create restricted data tokens to access personally identifiable information (PII) in specific API calls.
455
442
 
456
- **Example:**
457
-
458
443
  ```ruby
459
- client = Peddler::API::Tokens20210301.new("<AWS_REGION>", "<ACCESS_TOKEN>")
460
- response = client.create_restricted_data_token(
444
+ api = Peddler.tokens_2021_03_01(aws_region, access_token)
445
+ response = api.create_restricted_data_token(
461
446
  body: {
462
447
  restrictedResources: [
463
448
  {
@@ -471,40 +456,43 @@ response = client.create_restricted_data_token(
471
456
  restricted_data_token = response.parse["restrictedDataToken"]
472
457
 
473
458
  # Use the token in subsequent API calls
474
- orders_client = Peddler::API::Orders20211201.new("<AWS_REGION>", restricted_data_token)
475
- response = orders_client.get_order(
459
+ orders_api = Peddler.orders_2021_12_01("<AWS_REGION>", restricted_data_token)
460
+ response = orders_api.get_order(
476
461
  orderId: "123-1234567-1234567"
477
462
  )
478
- order_details = response.parse
463
+ response.parse
479
464
  ```
480
465
 
481
466
  #### Finances API (v0)
482
467
 
483
468
  Provides information about financial events for your seller account, such as order payments, refunds, and fees.
484
469
 
485
- **Example:**
486
-
487
470
  ```ruby
488
- client = Peddler::API::FinancesV0.new
489
- response = client.list_financial_events(
471
+ api = Peddler.finances_v0(aws_region, access_token)
472
+ response = api.list_financial_events(
490
473
  postedAfter: "2023-01-01T00:00:00Z",
491
474
  maxResultsPerPage: 100
492
475
  )
493
- financial_events = response.parse["FinancialEvents"]
476
+ response.parse
494
477
  ```
495
478
 
496
479
  #### Sellers API (V1)
497
480
 
498
481
  Provides information about seller's marketplaces and participation status.
499
482
 
500
- **Example:**
501
-
502
483
  ```ruby
503
- client = Peddler::API::SellersV1.new
504
- response = client.get_marketplace_participations
505
- participations = response.parse["payload"]
484
+ api = Peddler.sellers_v1(aws_region, access_token)
485
+ response = api.get_marketplace_participations
486
+ response.parse
506
487
  ```
507
488
 
489
+ ## TODO
490
+
491
+ - Code generate models to parse payload. Consider using `dry-struct`.
492
+ - Code generate the APIs section—descriptions and code examples—in this README here.
493
+ - Schedule code generation with GitHub Actions. Push new gem when models change.
494
+ - Review and consider applying [these patches][patches].
495
+
508
496
  [build]: https://github.com/hakanensari/peddler/actions
509
497
  [maintainability]: https://codeclimate.com/github/hakanensari/peddler/maintainability
510
498
  [test-coverage]: https://codeclimate.com/github/hakanensari/peddler/test_coverage
@@ -513,4 +501,6 @@ participations = response.parse["payload"]
513
501
  [register-application]: https://developer-docs.amazon.com/sp-api/docs/registering-your-application
514
502
  [view-credentials]: https://developer-docs.amazon.com/sp-api/docs/viewing-your-application-information-and-credentials
515
503
  [authorization]: https://developer-docs.amazon.com/sp-api/docs/authorizing-selling-partner-api-applications
504
+ [rate-limits]: https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits
516
505
  [httprb]: https://github.com/httprb/http
506
+ [patches]: https://github.com/bizon/selling-partner-api-sdk/tree/master/codegen/patches
@@ -3,6 +3,12 @@
3
3
  require "peddler/api"
4
4
 
5
5
  module Peddler
6
+ class << self
7
+ def amazon_warehousing_and_distribution_2024_05_09(...)
8
+ API::AmazonWarehousingAndDistribution20240509.new(...)
9
+ end
10
+ end
11
+
6
12
  class API
7
13
  # The Selling Partner API for Amazon Warehousing and Distribution
8
14
  #
@@ -11,35 +17,39 @@ module Peddler
11
17
  class AmazonWarehousingAndDistribution20240509 < API
12
18
  # Retrieves an AWD inbound shipment.
13
19
  #
14
- # @param [String] shipment_id ID for the shipment. A shipment contains the cases being inbounded.
15
- # @param [String] sku_quantities If equal to `SHOW`, the response includes the shipment SKU quantity details.
20
+ # @note This operation can make a static sandbox call.
21
+ # @param shipment_id [String] ID for the shipment. A shipment contains the cases being inbounded.
22
+ # @param sku_quantities [String] If equal to `SHOW`, the response includes the shipment SKU quantity details.
16
23
  # Defaults to `HIDE`, in which case the response does not contain SKU quantities
24
+ # @param rate_limit [Float] Requests per second
17
25
  # @return [Hash] The API response
18
- def get_inbound_shipment(shipment_id, sku_quantities: nil)
26
+ def get_inbound_shipment(shipment_id, sku_quantities: nil, rate_limit: 2.0)
19
27
  path = "/awd/2024-05-09/inboundShipments/#{shipment_id}"
20
28
  params = {
21
29
  "skuQuantities" => sku_quantities,
22
30
  }.compact
23
31
 
24
- rate_limit(2.0).get(path, params:)
32
+ meter(rate_limit).get(path, params:)
25
33
  end
26
34
 
27
35
  # Retrieves a summary of all the inbound AWD shipments associated with a merchant, with the ability to apply
28
36
  # optional filters.
29
37
  #
30
- # @param [String] sort_by Field to sort results by. By default, the response will be sorted by UPDATED_AT.
31
- # @param [String] sort_order Sort the response in ASCENDING or DESCENDING order. By default, the response will be
38
+ # @note This operation can make a static sandbox call.
39
+ # @param sort_by [String] Field to sort results by. By default, the response will be sorted by UPDATED_AT.
40
+ # @param sort_order [String] Sort the response in ASCENDING or DESCENDING order. By default, the response will be
32
41
  # sorted in DESCENDING order.
33
- # @param [String] shipment_status Filter by inbound shipment status.
34
- # @param [String] updated_after List the inbound shipments that were updated after a certain time (inclusive). The
35
- # date must be in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) format.
36
- # @param [String] updated_before List the inbound shipments that were updated before a certain time (inclusive).
37
- # The date must be in [ISO 8601](https://developer-docs.amazon.com/sp-api/docs/iso-8601) format.
38
- # @param [Integer] max_results Maximum number of results to return.
39
- # @param [String] next_token Token to retrieve the next set of paginated results.
42
+ # @param shipment_status [String] Filter by inbound shipment status.
43
+ # @param updated_after [String] List the inbound shipments that were updated after a certain time (inclusive). The
44
+ # date must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} format.
45
+ # @param updated_before [String] List the inbound shipments that were updated before a certain time (inclusive).
46
+ # The date must be in {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} format.
47
+ # @param max_results [Integer] Maximum number of results to return.
48
+ # @param next_token [String] Token to retrieve the next set of paginated results.
49
+ # @param rate_limit [Float] Requests per second
40
50
  # @return [Hash] The API response
41
51
  def list_inbound_shipments(sort_by: nil, sort_order: nil, shipment_status: nil, updated_after: nil,
42
- updated_before: nil, max_results: nil, next_token: nil)
52
+ updated_before: nil, max_results: 25, next_token: nil, rate_limit: 1.0)
43
53
  path = "/awd/2024-05-09/inboundShipments"
44
54
  params = {
45
55
  "sortBy" => sort_by,
@@ -51,19 +61,21 @@ module Peddler
51
61
  "nextToken" => next_token,
52
62
  }.compact
53
63
 
54
- rate_limit(1.0).get(path, params:)
64
+ meter(rate_limit).get(path, params:)
55
65
  end
56
66
 
57
67
  # Lists AWD inventory associated with a merchant with the ability to apply optional filters.
58
68
  #
59
- # @param [String] sku Filter by seller or merchant SKU for the item.
60
- # @param [String] sort_order Sort the response in `ASCENDING` or `DESCENDING` order.
61
- # @param [String] details Set to `SHOW` to return summaries with additional inventory details. Defaults to `HIDE,`
69
+ # @note This operation can make a static sandbox call.
70
+ # @param sku [String] Filter by seller or merchant SKU for the item.
71
+ # @param sort_order [String] Sort the response in `ASCENDING` or `DESCENDING` order.
72
+ # @param details [String] Set to `SHOW` to return summaries with additional inventory details. Defaults to `HIDE,`
62
73
  # which returns only inventory summary totals.
63
- # @param [String] next_token Token to retrieve the next set of paginated results.
64
- # @param [Integer] max_results Maximum number of results to return.
74
+ # @param next_token [String] Token to retrieve the next set of paginated results.
75
+ # @param max_results [Integer] Maximum number of results to return.
76
+ # @param rate_limit [Float] Requests per second
65
77
  # @return [Hash] The API response
66
- def list_inventory(sku: nil, sort_order: nil, details: nil, next_token: nil, max_results: nil)
78
+ def list_inventory(sku: nil, sort_order: nil, details: nil, next_token: nil, max_results: 25, rate_limit: 2.0)
67
79
  path = "/awd/2024-05-09/inventory"
68
80
  params = {
69
81
  "sku" => sku,
@@ -73,7 +85,7 @@ module Peddler
73
85
  "maxResults" => max_results,
74
86
  }.compact
75
87
 
76
- rate_limit(2.0).get(path, params:)
88
+ meter(rate_limit).get(path, params:)
77
89
  end
78
90
  end
79
91
  end