peddler 5.0.0.pre.8 → 5.1.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.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +81 -768
  3. data/lib/peddler/acronyms.rb +1 -0
  4. data/lib/peddler/api.rb +35 -62
  5. data/lib/peddler/apis/amazon_warehousing_and_distribution_2024_05_09.rb +11 -11
  6. data/lib/peddler/apis/aplus_content_2020_11_01.rb +10 -10
  7. data/lib/peddler/apis/application_integrations_2024_04_01.rb +3 -3
  8. data/lib/peddler/apis/application_management_2023_11_30.rb +1 -1
  9. data/lib/peddler/apis/catalog_items_2020_12_01.rb +2 -2
  10. data/lib/peddler/apis/catalog_items_2022_04_01.rb +2 -2
  11. data/lib/peddler/apis/catalog_items_v0.rb +1 -1
  12. data/lib/peddler/apis/data_kiosk_2023_11_15.rb +5 -5
  13. data/lib/peddler/apis/delivery_by_amazon_2022_07_01/error.rb +23 -0
  14. data/lib/peddler/apis/delivery_by_amazon_2022_07_01/error_list.rb +18 -0
  15. data/lib/peddler/apis/delivery_by_amazon_2022_07_01/get_invoice_status_response.rb +26 -0
  16. data/lib/peddler/apis/delivery_by_amazon_2022_07_01/submit_invoice_request.rb +31 -0
  17. data/lib/peddler/apis/delivery_by_amazon_2022_07_01/submit_invoice_response.rb +17 -0
  18. data/lib/peddler/apis/delivery_by_amazon_2022_07_01.rb +59 -0
  19. data/lib/peddler/apis/easy_ship_2022_03_23.rb +5 -5
  20. data/lib/peddler/apis/external_fulfillment_shipments_2024_09_11/shipment.rb +3 -0
  21. data/lib/peddler/apis/fba_inbound_eligibility_v1.rb +1 -1
  22. data/lib/peddler/apis/fba_inventory_v1.rb +1 -1
  23. data/lib/peddler/apis/feeds_2021_06_30.rb +6 -6
  24. data/lib/peddler/apis/finances_2024_06_19/amazon_pay_context.rb +2 -2
  25. data/lib/peddler/apis/finances_2024_06_19/breakdown.rb +3 -4
  26. data/lib/peddler/apis/finances_2024_06_19/context.rb +11 -11
  27. data/lib/peddler/apis/finances_2024_06_19/contexts.rb +1 -1
  28. data/lib/peddler/apis/finances_2024_06_19/deferred_context.rb +1 -1
  29. data/lib/peddler/apis/finances_2024_06_19/error.rb +1 -1
  30. data/lib/peddler/apis/finances_2024_06_19/error_list.rb +1 -1
  31. data/lib/peddler/apis/finances_2024_06_19/item.rb +3 -3
  32. data/lib/peddler/apis/finances_2024_06_19/item_related_identifier.rb +1 -1
  33. data/lib/peddler/apis/finances_2024_06_19/item_related_identifiers.rb +1 -1
  34. data/lib/peddler/apis/finances_2024_06_19/items.rb +1 -1
  35. data/lib/peddler/apis/finances_2024_06_19/marketplace_details.rb +2 -3
  36. data/lib/peddler/apis/finances_2024_06_19/payments_context.rb +5 -5
  37. data/lib/peddler/apis/finances_2024_06_19/product_context.rb +4 -4
  38. data/lib/peddler/apis/finances_2024_06_19/related_identifier.rb +2 -2
  39. data/lib/peddler/apis/finances_2024_06_19/selling_partner_metadata.rb +3 -3
  40. data/lib/peddler/apis/finances_2024_06_19/time_range_context.rb +3 -3
  41. data/lib/peddler/apis/finances_2024_06_19/transaction.rb +8 -10
  42. data/lib/peddler/apis/finances_2024_06_19/transactions.rb +1 -1
  43. data/lib/peddler/apis/finances_2024_06_19/transactions_payload.rb +4 -2
  44. data/lib/peddler/apis/finances_2024_06_19.rb +24 -13
  45. data/lib/peddler/apis/finances_v0/adhoc_disbursement_event.rb +1 -3
  46. data/lib/peddler/apis/finances_v0/adjustment_event.rb +11 -18
  47. data/lib/peddler/apis/finances_v0/adjustment_item.rb +3 -3
  48. data/lib/peddler/apis/finances_v0/affordability_expense_event.rb +6 -7
  49. data/lib/peddler/apis/finances_v0/capacity_reservation_billing_event.rb +1 -1
  50. data/lib/peddler/apis/finances_v0/charge_component.rb +37 -35
  51. data/lib/peddler/apis/finances_v0/charge_refund_event.rb +2 -6
  52. data/lib/peddler/apis/finances_v0/coupon_payment_event.rb +1 -1
  53. data/lib/peddler/apis/finances_v0/debt_recovery_event.rb +1 -5
  54. data/lib/peddler/apis/finances_v0/debt_recovery_item.rb +4 -4
  55. data/lib/peddler/apis/finances_v0/direct_payment.rb +7 -7
  56. data/lib/peddler/apis/finances_v0/ebt_refund_reimbursement_only_event.rb +23 -0
  57. data/lib/peddler/apis/finances_v0/ebt_refund_reimbursement_only_event_list.rb +18 -0
  58. data/lib/peddler/apis/finances_v0/failed_adhoc_disbursement_event.rb +3 -9
  59. data/lib/peddler/apis/finances_v0/failed_adhoc_disbursement_event_list.rb +1 -1
  60. data/lib/peddler/apis/finances_v0/fba_liquidation_event.rb +1 -1
  61. data/lib/peddler/apis/finances_v0/financial_event_group.rb +5 -7
  62. data/lib/peddler/apis/finances_v0/financial_events.rb +4 -1
  63. data/lib/peddler/apis/finances_v0/list_financial_event_groups_payload.rb +1 -1
  64. data/lib/peddler/apis/finances_v0/list_financial_event_groups_response.rb +3 -3
  65. data/lib/peddler/apis/finances_v0/list_financial_events_payload.rb +1 -1
  66. data/lib/peddler/apis/finances_v0/list_financial_events_response.rb +3 -3
  67. data/lib/peddler/apis/finances_v0/loan_servicing_event.rb +3 -3
  68. data/lib/peddler/apis/finances_v0/network_commingling_transaction_event.rb +3 -3
  69. data/lib/peddler/apis/finances_v0/pay_with_amazon_event.rb +5 -5
  70. data/lib/peddler/apis/finances_v0/product_ads_payment_event.rb +4 -4
  71. data/lib/peddler/apis/finances_v0/removal_shipment_adjustment_event.rb +2 -2
  72. data/lib/peddler/apis/finances_v0/removal_shipment_adjustment_event_list.rb +1 -1
  73. data/lib/peddler/apis/finances_v0/removal_shipment_event.rb +2 -2
  74. data/lib/peddler/apis/finances_v0/removal_shipment_item.rb +5 -6
  75. data/lib/peddler/apis/finances_v0/removal_shipment_item_adjustment.rb +8 -9
  76. data/lib/peddler/apis/finances_v0/removal_shipment_item_list.rb +1 -1
  77. data/lib/peddler/apis/finances_v0/rental_transaction_event.rb +17 -16
  78. data/lib/peddler/apis/finances_v0/retrocharge_event.rb +2 -2
  79. data/lib/peddler/apis/finances_v0/retrocharge_event_list.rb +1 -1
  80. data/lib/peddler/apis/finances_v0/safet_reimbursement_event_list.rb +1 -1
  81. data/lib/peddler/apis/finances_v0/safet_reimbursement_item_list.rb +1 -1
  82. data/lib/peddler/apis/finances_v0/seller_deal_payment_event.rb +2 -2
  83. data/lib/peddler/apis/finances_v0/seller_review_enrollment_payment_event.rb +1 -1
  84. data/lib/peddler/apis/finances_v0/solution_provider_credit_event.rb +1 -1
  85. data/lib/peddler/apis/finances_v0/solution_provider_credit_event_list.rb +1 -1
  86. data/lib/peddler/apis/finances_v0/tax_withheld_component.rb +2 -3
  87. data/lib/peddler/apis/finances_v0/tax_withholding_event.rb +1 -1
  88. data/lib/peddler/apis/finances_v0/tax_withholding_event_list.rb +1 -1
  89. data/lib/peddler/apis/finances_v0/tax_withholding_period.rb +1 -1
  90. data/lib/peddler/apis/finances_v0/value_added_service_charge_event.rb +1 -3
  91. data/lib/peddler/apis/finances_v0.rb +60 -47
  92. data/lib/peddler/apis/fulfillment_inbound_2024_03_20/delivery_window_option.rb +2 -1
  93. data/lib/peddler/apis/fulfillment_inbound_2024_03_20/selected_delivery_window.rb +2 -1
  94. data/lib/peddler/apis/fulfillment_inbound_2024_03_20.rb +90 -142
  95. data/lib/peddler/apis/fulfillment_inbound_v0.rb +6 -6
  96. data/lib/peddler/apis/fulfillment_outbound_2020_07_01.rb +14 -17
  97. data/lib/peddler/apis/invoices_2024_06_19.rb +7 -7
  98. data/lib/peddler/apis/listings_items_2020_09_01.rb +3 -3
  99. data/lib/peddler/apis/listings_items_2021_08_01.rb +5 -5
  100. data/lib/peddler/apis/listings_restrictions_2021_08_01.rb +1 -1
  101. data/lib/peddler/apis/merchant_fulfillment_v0.rb +5 -5
  102. data/lib/peddler/apis/messaging_v1.rb +11 -11
  103. data/lib/peddler/apis/notifications_v1.rb +8 -8
  104. data/lib/peddler/apis/orders_v0/buyer_info.rb +0 -3
  105. data/lib/peddler/apis/orders_v0/order_buyer_info.rb +0 -3
  106. data/lib/peddler/apis/orders_v0.rb +12 -15
  107. data/lib/peddler/apis/product_fees_v0.rb +3 -3
  108. data/lib/peddler/apis/product_pricing_2022_05_01.rb +2 -2
  109. data/lib/peddler/apis/product_pricing_v0.rb +6 -6
  110. data/lib/peddler/apis/product_type_definitions_2020_09_01.rb +2 -2
  111. data/lib/peddler/apis/replenishment_2022_11_07/get_selling_partner_metrics_response_metric.rb +66 -22
  112. data/lib/peddler/apis/replenishment_2022_11_07/list_offer_metrics_response_offer.rb +13 -13
  113. data/lib/peddler/apis/replenishment_2022_11_07.rb +3 -3
  114. data/lib/peddler/apis/reports_2021_06_30.rb +9 -9
  115. data/lib/peddler/apis/sales_v1.rb +1 -1
  116. data/lib/peddler/apis/seller_wallet_2024_03_01/bank_account.rb +23 -18
  117. data/lib/peddler/apis/seller_wallet_2024_03_01/payee_contact_information.rb +54 -0
  118. data/lib/peddler/apis/seller_wallet_2024_03_01/transaction.rb +7 -3
  119. data/lib/peddler/apis/seller_wallet_2024_03_01/transaction_initiation_request.rb +3 -3
  120. data/lib/peddler/apis/seller_wallet_2024_03_01.rb +7 -2
  121. data/lib/peddler/apis/sellers_v1.rb +2 -2
  122. data/lib/peddler/apis/services_v1.rb +17 -17
  123. data/lib/peddler/apis/shipment_invoicing_v0.rb +3 -3
  124. data/lib/peddler/apis/shipping_v1.rb +9 -9
  125. data/lib/peddler/apis/shipping_v2.rb +19 -19
  126. data/lib/peddler/apis/solicitations_v1.rb +2 -2
  127. data/lib/peddler/apis/tokens_2021_03_01.rb +1 -1
  128. data/lib/peddler/apis/transfers_2024_06_01.rb +2 -2
  129. data/lib/peddler/apis/uploads_2020_11_01.rb +1 -1
  130. data/lib/peddler/apis/vendor_direct_fulfillment_inventory_v1.rb +1 -1
  131. data/lib/peddler/apis/vendor_direct_fulfillment_orders_2021_12_28.rb +3 -3
  132. data/lib/peddler/apis/vendor_direct_fulfillment_orders_v1.rb +3 -3
  133. data/lib/peddler/apis/vendor_direct_fulfillment_payments_v1.rb +1 -1
  134. data/lib/peddler/apis/vendor_direct_fulfillment_shipping_2021_12_28.rb +11 -11
  135. data/lib/peddler/apis/vendor_direct_fulfillment_shipping_v1.rb +9 -9
  136. data/lib/peddler/apis/vendor_direct_fulfillment_transactions_2021_12_28.rb +1 -1
  137. data/lib/peddler/apis/vendor_direct_fulfillment_transactions_v1.rb +1 -1
  138. data/lib/peddler/apis/vendor_invoices_v1.rb +1 -1
  139. data/lib/peddler/apis/vendor_orders_v1.rb +4 -4
  140. data/lib/peddler/apis/vendor_shipments_v1/package_item_details.rb +16 -0
  141. data/lib/peddler/apis/vendor_shipments_v1/regulation_references.rb +32 -0
  142. data/lib/peddler/apis/vendor_shipments_v1.rb +5 -5
  143. data/lib/peddler/apis/vendor_transaction_status_v1.rb +1 -1
  144. data/lib/peddler/data_kiosk/economics20240315/analytics_economics20240315.rb +5 -0
  145. data/lib/peddler/data_kiosk/economics20240315.json +340 -7
  146. data/lib/peddler/data_kiosk/vendor_analytics20240930/traffic.rb +5 -0
  147. data/lib/peddler/data_kiosk/vendor_analytics20240930.json +12 -0
  148. data/lib/peddler/reports/vendor_real_time_sales/report.rb +1 -1
  149. data/lib/peddler/response.rb +1 -1
  150. data/lib/peddler/version.rb +1 -1
  151. data/lib/peddler.rb +2 -0
  152. data/sig/peddler/api.rbs +13 -23
  153. data/sig/peddler/apis/delivery_by_amazon_2022_07_01.rbs +85 -0
  154. data/sig/peddler/apis/external_fulfillment_shipments_2024_09_11.rbs +8 -7
  155. data/sig/peddler/apis/finances_2024_06_19.rbs +1 -1
  156. data/sig/peddler/apis/finances_v0.rbs +30 -7
  157. data/sig/peddler/apis/fulfillment_inbound_2024_03_20.rbs +45 -45
  158. data/sig/peddler/apis/fulfillment_outbound_2020_07_01.rbs +1 -1
  159. data/sig/peddler/apis/orders_v0.rbs +15 -17
  160. data/sig/peddler/apis/replenishment_2022_11_07.rbs +18 -7
  161. data/sig/peddler/apis/seller_wallet_2024_03_01.rbs +49 -42
  162. data/sig/peddler/apis/vendor_shipments_v1.rbs +30 -41
  163. data/sig/peddler/data_kiosk/economics20240315.rbs +8 -7
  164. data/sig/peddler/data_kiosk/vendor_analytics20240930.rbs +8 -7
  165. data/sig/peddler/reports/vendor_real_time_sales.rbs +6 -6
  166. data/sig/peddler.rbs +4 -0
  167. metadata +13 -5
  168. data/lib/peddler/apis/seller_wallet_2024_03_01/account_holder_address.rb +0 -36
  169. data/lib/peddler/apis/vendor_shipments_v1/packed_quantity.rb +0 -25
  170. data/lib/peddler/apis/vendor_shipments_v1/purchase_order_item_details.rb +0 -18
data/README.md CHANGED
@@ -2,36 +2,26 @@
2
2
 
3
3
  [![Build](https://github.com/lineofflight/peddler/actions/workflows/ci.yml/badge.svg)][build]
4
4
 
5
- > **IMPORTANT:** This README is for the v5 pre-release. For the latest stable version, see the [v4.9.0 README](https://github.com/hakanensari/peddler/blob/v4.9.0/README.md).
6
-
7
- **Peddler** is a Ruby interface to the [Amazon Selling Partner API (SP-API)][api-docs]. The SP-API enables Amazon sellers and vendors to programmatically access their data on orders, shipments, payments, and more.
5
+ Peddler is a Ruby interface to the [Amazon Selling Partner API (SP-API)][api-docs]. The SP-API enables Amazon sellers and vendors to programmatically access their data on orders, shipments, payments, and more.
8
6
 
9
7
  Peddler is automatically generated from the latest Open API models provided by Amazon.
10
8
 
11
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.
12
10
 
13
11
  - [API docs][api-docs]
14
- - [Swagger models][swagger-models]
12
+ - [OpenAPI models][openapi-models]
15
13
  - [API samples][api-samples]
16
14
 
17
15
  <img src="https://github.com/hakanensari/peddler/blob/main/images/peddler.jpg?raw=true" alt="Peddler" style="max-width: 830px" />
18
16
 
19
17
  ## Installation
20
18
 
21
- Add this line to your Gemfile.
22
-
23
- ```ruby
24
- gem "peddler", "~> 5.0.0.pre.8"
25
- ```
26
-
27
- And then execute:
28
-
29
- ```shell
30
- bundle install
31
- ```
19
+ Add to your Gemfile.
32
20
 
33
21
  ## Usage
34
22
 
23
+ ### Authorization
24
+
35
25
  Set your LWA credentials in your environment.
36
26
 
37
27
  ```shell
@@ -39,14 +29,6 @@ export LWA_CLIENT_ID=<YOUR_CLIENT_ID>
39
29
  export LWA_CLIENT_SECRET=<YOUR_CLIENT_SECRET>
40
30
  ```
41
31
 
42
- Require the library.
43
-
44
- ```ruby
45
- require "peddler"
46
- ```
47
-
48
- ### Authorization
49
-
50
32
  A seller or vendor [provides you a refresh token][authorization] to access their data on Amazon.
51
33
 
52
34
  ```ruby
@@ -56,7 +38,7 @@ response = Peddler::LWA.request(
56
38
  refresh_token = response.parse.refresh_token
57
39
  ```
58
40
 
59
- You use this to generate a temporary access token to authenticate individual API requests.
41
+ Use this to generate a temporary access token to authenticate individual requests.
60
42
 
61
43
  ```ruby
62
44
  response = Peddler::LWA.request(
@@ -74,7 +56,7 @@ response = Peddler::LWA.request(
74
56
  access_token = response.parse.access_token
75
57
  ```
76
58
 
77
- If you haven't set your LWA credentials as environment variables, pass them directly when requesting the token.
59
+ In place of environment variables, you can set them directly when requesting the token.
78
60
 
79
61
  ```ruby
80
62
  response = Peddler::LWA.request(
@@ -85,9 +67,9 @@ response = Peddler::LWA.request(
85
67
  access_token = response.parse.access_token
86
68
  ```
87
69
 
88
- Access tokens are valid for one hour. To optimize performance, cache the token and reuse across calls.
70
+ Access tokens are valid for one hour. To optimize performance, cache and reuse across calls.
89
71
 
90
- 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:
72
+ For example,
91
73
 
92
74
  ```ruby
93
75
  class Seller
@@ -103,30 +85,24 @@ end
103
85
 
104
86
  ### Rate limiting
105
87
 
106
- Amazon's SP-API imposes [rate limits][rate-limits] on operations. Override the default rate limit by passing a `:rate_limit` parameter when calling an operation.
88
+ Amazon's SP-API imposes [rate limits][rate-limits] on operations. Override the default value by passing a `:rate_limit` parameter when calling an operation.
107
89
 
108
- 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.
90
+ Provide an optional `:retries` argument when initializing an API to specify retry attempts if throttled. Default is 0 (no retries). If set, Peddler retries with exponential backoff.
109
91
 
110
92
  ```ruby
111
93
  api = Peddler.orders_v0.new(aws_region, access_token, retries: 3)
112
- api.get_orders(
113
- marketplaceIds: ["ATVPDKIKX0DER"],
114
- createdAfter: "2023-01-01T00:00:00Z"
115
- )
94
+ api.get_orders("...": "...")
116
95
  ```
117
96
 
118
97
  ### Typed Responses
119
98
 
120
- Peddler provides typed response parsing using the [Structure gem](https://github.com/hakanensari/structure), offering runtime type checking and better IDE support. Types are based on Ruby's [Data class](https://docs.ruby-lang.org/en/3.4/Data.html) and are lazy-loaded only when you first call `parse`.
99
+ Peddler provides typed response parsing using the [Structure gem](https://github.com/hakanensari/structure), offering runtime type checking and better IDE support. Types are based on Ruby's [Data class](https://docs.ruby-lang.org/en/4.0/Data.html) and are lazy-loaded.
121
100
 
122
101
  ```ruby
123
102
  api = Peddler.orders.new(aws_region, access_token)
124
103
 
125
104
  # Get orders with type-safe response
126
- response = api.get_orders(
127
- marketplaceIds: ["ATVPDKIKX0DER"],
128
- createdAfter: "2023-01-01T00:00:00Z"
129
- )
105
+ response = api.get_orders("...": "...")
130
106
 
131
107
  # Use .parse to get typed Data objects
132
108
  orders = response.parse.payload.orders # Returns array of Order Data objects
@@ -189,246 +165,74 @@ You can also simply use the latest version:
189
165
  api = Peddler.<api_name>.new(aws_region, access_token, options)
190
166
  ```
191
167
 
192
- Below is a comprehensive list of all available APIs organized by category:
168
+ Available APIs by category:
193
169
 
194
170
  #### Orders and Financial APIs
195
171
 
196
- - **Orders API (v0)**: Retrieve and manage orders
197
- - **Finances API (2024-06-19, 2024-06-01, v0)**: Get financial data including transaction details, payments, and refunds
198
- - **Invoices API (2024-06-19)**: Manage billing invoices
199
- - **Sales API (v1)**: Get order metrics and sales data
172
+ - **Orders API**: Retrieve and manage orders
173
+ - **Finances API**: Financial data, payments, refunds
174
+ - **Invoices API**: Manage billing invoices
175
+ - **Sales API**: Order metrics and sales data
200
176
 
201
177
  ```ruby
202
178
  api = Peddler.orders.new(aws_region, access_token)
203
- response = api.get_orders(
204
- marketplaceIds: ["ATVPDKIKX0DER"],
205
- createdAfter: "2023-01-01T00:00:00Z"
206
- )
179
+ response = api.get_orders("...": "...")
207
180
  orders = response.parse.payload.orders
208
- order_id = orders.first.amazon_order_id
209
-
210
- # Or use .to_h or .dig to parse response as a hash
211
- orders = response.dig("payload", "orders")
212
- order_id = response.dig("payload", "orders", 0, "amazonOrderId")
213
-
214
- # For sandbox testing
215
- api.sandbox.get_orders(
216
- marketplaceIds: ["ATVPDKIKX0DER"],
217
- createdAfter: "TEST_CASE_200"
218
- )
219
181
  ```
220
182
 
221
183
  #### Catalog and Listing APIs
222
184
 
223
- - **Catalog Items API (2022-04-01, 2020-12-01, v0)**: Access Amazon's catalog data
224
- - **Listings Items API (2021-08-01, 2020-09-01)**: Create and update listings
225
- - **Listings Restrictions API (2021-08-01)**: Check listing eligibility
226
- - **Product Type Definitions API (2020-09-01)**: Get schema requirements for listings
227
- - **A+ Content API (2020-11-01)**: Create and manage enhanced marketing content
228
- - **Product Pricing API (2022-05-01, v0)**: Get pricing information
229
- - **Product Fees API (v0)**: Retrieve fee estimates for products
185
+ - **Catalog Items API**: Access Amazon's catalog data
186
+ - **Listings Items API**: Create and update listings
187
+ - **Listings Restrictions API**: Check listing eligibility
188
+ - **Product Type Definitions API**: Get schema requirements for listings
189
+ - **A+ Content API**: Create and manage enhanced marketing content
190
+ - **Product Pricing API**: Get pricing information
191
+ - **Product Fees API**: Retrieve fee estimates for products
230
192
 
231
193
  ```ruby
232
194
  api = Peddler.catalog_items.new(aws_region, access_token)
233
- response = api.get_catalog_item(
234
- marketplaceIds: ["ATVPDKIKX0DER"],
235
- asin: "B08N5WRWNW"
236
- )
237
- response.parse.payload.asin # => "B08N5WRWNW"
238
-
239
- # Search catalog items by identifier
240
- response = api.search_catalog_items(
241
- ["ATVPDKIKX0DER"],
242
- identifiers: "B08N5WRWNW",
243
- identifiers_type: "ASIN"
244
- )
245
- search_results = response.parse
195
+ response = api.get_catalog_item("...": "...")
196
+ item = response.parse.payload
246
197
  ```
247
198
 
248
199
  #### Fulfillment and Inventory APIs
249
200
 
250
- - **Fulfillment Inbound API (2024-03-20, v0)**: Send inventory to FBA
251
- - **Fulfillment Outbound API (2020-07-01)**: Create and track FBA orders
252
- - **FBA Inventory API (v1)**: Manage FBA inventory quantities
253
- - **FBA Inbound Eligibility API (v1)**: Check product eligibility for FBA
254
- - **Merchant Fulfillment API (v0)**: Create shipping labels for self-fulfilled orders
255
- - **Easy Ship API (2022-03-23)**: Manage Amazon's carrier service for deliveries
256
- - **Shipping APIs (v1, v2)**: Create shipments and purchase shipping labels
257
- - **Replenishment API (2022-11-07)**: Manage inventory replenishment
258
- - **Amazon Warehousing and Distribution API (2024-05-09)**: Manage fulfillment warehousing
259
- - **Supply Sources API (2020-07-01)**: Manage supply/inventory sources
260
- - **Shipment Invoicing API (v0)**: Manage shipment-related invoices
201
+ - **Fulfillment Inbound API**: Send inventory to FBA
202
+ - **Fulfillment Outbound API**: Create and track FBA orders
203
+ - **FBA Inventory API**: Manage FBA inventory quantities
204
+ - **FBA Inbound Eligibility API**: Check product eligibility for FBA
205
+ - **Merchant Fulfillment API**: Create shipping labels for self-fulfilled orders
206
+ - **Easy Ship API**: Manage Amazon's carrier service
207
+ - **Shipping APIs**: Create shipments and purchase shipping labels
208
+ - **Replenishment API**: Manage inventory replenishment
209
+ - **Amazon Warehousing and Distribution API**: Manage fulfillment warehousing
210
+ - **Supply Sources API**: Manage supply/inventory sources
211
+ - **Shipment Invoicing API**: Manage shipment-related invoices
261
212
 
262
213
  ```ruby
263
- # FBA outbound example
264
214
  api = Peddler.fulfillment_outbound.new(aws_region, access_token)
265
- api.create_fulfillment_order(
266
- body: {
267
- sellerFulfillmentOrderId: "ORDER123",
268
- displayableOrderId: "ORDER123",
269
- displayableOrderDate: Time.now.iso8601,
270
- shippingSpeedCategory: "Standard",
271
- destinationAddress: {
272
- name: "Customer Name",
273
- addressLine1: "123 Main St",
274
- city: "Seattle",
275
- stateOrRegion: "WA",
276
- postalCode: "98101",
277
- countryCode: "US"
278
- },
279
- items: [
280
- {
281
- sellerSku: "SKU123",
282
- sellerFulfillmentOrderItemId: "ITEM123",
283
- quantity: 1
284
- }
285
- ]
286
- }
287
- )
215
+ response = api.create_fulfillment_order(body: { "...": "..." })
288
216
  ```
289
217
 
290
218
  #### Data Management APIs
291
219
 
292
- - **Feeds API (2021-06-30)**: Upload data to Amazon to update listings, prices, inventory, and more
293
- - **Reports API (2021-06-30)**: Request and download reports about orders, inventory, fulfillment, and more
294
- - **Uploads API (2020-11-01)**: Upload files for various SP-API operations
295
- - **Data Kiosk API (2023-11-15, 2024-03-15, 2024-04-24, 2024-09-30)**: Access and manage analytical data with GraphQL queries
220
+ - **Feeds API**: Upload data to Amazon (listings, prices, inventory, etc.)
221
+ - **Reports API**: Request and download reports (orders, inventory, fulfillment, etc.)
222
+ - **Uploads API**: Upload files for various SP-API operations
223
+ - **Data Kiosk API**: Access analytical data with GraphQL queries
296
224
 
297
225
  ```ruby
226
+ # Feeds API - create feed document, upload, submit
298
227
  api = Peddler.feeds.new(aws_region, access_token)
299
-
300
- # Complete Feeds API Workflow:
301
- # 1. Create a feed document (input feed document)
302
- # 2. Upload content to the document
303
- # 3. Create feed referencing the document
304
- # 4. Wait for feed to complete (e.g., SQS notification)
305
- # 5. Get feed document (result feed document)
306
- # 6. Download results to see processing outcome
307
-
308
- # Step 1: Create feed document (input document)
309
- document_response = api.create_feed_document(
310
- contentType: "text/xml; charset=UTF-8"
311
- )
312
-
313
- # The `dig` method safely navigates the response hash
314
- # If the response structure is:
315
- # {
316
- # "feedDocumentId": "amzn1.tortuga.3.abc123...",
317
- # "url": "...",
318
- # "encryptionDetails": {
319
- # "standard": "AES",
320
- # "key": "encryption-key",
321
- # "initializationVector": "vector-value"
322
- # }
323
- # }
324
-
325
- # Access top-level keys with dig
326
- feed_document_id = document_response.dig("feedDocumentId")
327
- upload_url = document_response.dig("url")
328
-
329
- # Access nested keys - returns nil if any key in the path is missing
330
- encryption_key = document_response.dig("encryptionDetails", "key")
331
-
332
- # Step 2: Upload feed content to the input document
333
- feed_content = File.read("inventory_update.xml")
334
- api.upload_feed_document(upload_url, feed_content, "text/xml; charset=UTF-8")
335
-
336
- # Step 3: Create feed referencing the input document
337
- feed_response = api.create_feed(
338
- feedType: "POST_INVENTORY_AVAILABILITY_DATA",
339
- marketplaceIds: ["ATVPDKIKX0DER"],
340
- inputFeedDocumentId: feed_document_id
341
- )
342
- feed_id = feed_response.dig("feedId")
343
-
344
- # Step 4: Wait for feed to complete (polling or SQS notification)
345
- # Poll until status is "DONE", "FATAL", or "CANCELLED"
346
- loop do
347
- feed_status = api.get_feed(feed_id)
348
- status = feed_status.dig("processingStatus")
349
- break if ["DONE", "FATAL", "CANCELLED"].include?(status)
350
- sleep 30 # Wait 30 seconds before checking again
351
- end
352
-
353
- # Step 5: Get feed document (result document with processing results)
354
- result_document_id = feed_status.dig("resultFeedDocumentId")
355
- result_document = api.get_feed_document(result_document_id) if result_document_id
356
-
357
- # Step 6: Download results to see processing outcome
358
- if result_document
359
- download_url = result_document.dig("url")
360
- response = HTTP.get(download_url)
361
- content = if result_document.dig("compressionAlgorithm") == "GZIP"
362
- Zlib::GzipReader.new(response).read
363
- else
364
- response.to_s
365
- end
366
- # Parse content to check for errors/success
367
- end
368
-
369
- # JSON feed example
370
- json_document = api.create_feed_document(
371
- { "contentType" => "application/json; charset=UTF-8" }
372
- )
373
- json_feed_content = JSON.generate({
374
- "header": {
375
- "sellerId": "SELLER_ID",
376
- "version": "2.0",
377
- "issueLocale": "en_US"
378
- },
379
- "messages": [
380
- {
381
- "messageId": 1,
382
- "sku": "SKU123",
383
- "operationType": "UPDATE",
384
- "productType": "PRODUCT",
385
- "attributes": {
386
- # Your product attributes here
387
- }
388
- }
389
- ]
390
- })
391
- api.upload_feed_document(json_document.dig("url"), json_feed_content, "application/json; charset=UTF-8")
392
- ```
393
-
394
- **Parsing Feed Results:**
395
-
396
- After feed processing completes, parse the result document with type-safe data classes:
397
-
398
- ```ruby
399
- # Get feed processing result document
400
- result_document = api.get_feed_document(result_feed_document_id)
401
- result_content = HTTP.get(result_document.dig("url")).to_s
402
-
403
- # Handle compression if needed
404
- if result_document.dig("compressionAlgorithm") == "GZIP"
405
- require "zlib"
406
- result_content = Zlib::GzipReader.new(StringIO.new(result_content)).read
407
- end
408
-
409
- # Parse with type safety
410
- result_json = JSON.parse(result_content)
411
- report = Peddler::Feeds::ListingsFeedProcessingReportSchema.parse(result_json)
412
-
413
- # Access structured processing results
414
- puts "Messages Processed: #{report.summary.messages_processed}"
415
- puts "Messages Accepted: #{report.summary.messages_accepted}"
416
- puts "Messages with Errors: #{report.summary.messages_with_error}"
417
- puts "Messages with Warnings: #{report.summary.messages_with_warning}"
418
-
419
- # Iterate through issues with type-safe access
420
- report.issues.each do |issue|
421
- puts "\nIssue in message #{issue.message_id}:"
422
- puts " Severity: #{issue.severity}"
423
- puts " Code: #{issue.code}"
424
- puts " Message: #{issue.message}"
425
- puts " SKU: #{issue.sku}" if issue.sku
426
- end
228
+ document = api.create_feed_document(contentType: "text/xml; charset=UTF-8")
229
+ api.upload_feed_document(document.dig("url"), File.read("feed.xml"), "text/xml")
230
+ feed = api.create_feed(feedType: "POST_INVENTORY_AVAILABILITY_DATA", marketplaceIds: ["ATVPDKIKX0DER"], inputFeedDocumentId: document.dig("feedDocumentId"))
427
231
  ```
428
232
 
429
233
  #### Data Kiosk API
430
234
 
431
- The Data Kiosk API provides access to Amazon's analytical data through GraphQL queries. Peddler supports four Data Kiosk schema versions, each with type-safe Structure classes for parsing responses.
235
+ The Data Kiosk API provides access to Amazon's analytical data through GraphQL queries. Peddler supports four Data Kiosk schema versions, each with type-safe classes for parsing responses.
432
236
 
433
237
  **Available Schemas:**
434
238
 
@@ -437,545 +241,52 @@ The Data Kiosk API provides access to Amazon's analytical data through GraphQL q
437
241
  - **Economics20240315**: Economics and profitability data
438
242
  - **VendorAnalytics20240930**: Vendor-specific analytics and forecasting data
439
243
 
440
- **Basic Example:**
441
-
442
244
  ```ruby
443
245
  api = Peddler.data_kiosk.new(aws_region, access_token)
444
-
445
- # Create a Data Kiosk query request
446
- response = api.create_query({
447
- query: """
448
- query {
449
- salesAndTrafficByDate(
450
- startDate: "2024-01-01",
451
- endDate: "2024-01-31",
452
- marketplaceIds: ["ATVPDKIKX0DER"]
453
- ) {
454
- data {
455
- date
456
- orderItems
457
- sales
458
- pageViews
459
- sessions
460
- }
461
- }
462
- }
463
- """
464
- })
465
-
466
- # Get the query ID
246
+ response = api.create_query(query: "query { salesAndTrafficByDate(...) { data { date sales } } }")
467
247
  query_id = response.dig("payload", "queryId")
468
-
469
- # Poll for query completion
470
- loop do
471
- status = api.get_query(query_id)
472
- processing_status = status.dig("payload", "processingStatus")
473
- break if ["DONE", "FATAL"].include?(processing_status)
474
- sleep 2
475
- end
476
-
477
- # Download the report document
478
- result_document_id = status.dig("payload", "reportDocumentId")
479
- document = api.get_report_document(result_document_id)
480
- report_url = document.dig("url")
481
-
482
- # Parse the response
483
- require "net/http"
484
- http_response = HTTP.get(report_url)
485
- parsed_data = JSON.parse(http_response.to_s)
486
-
487
- # Use type-safe parsing with Peddler's Structure classes
488
- sales_data = Peddler::DataKiosk::SalesAndTraffic20231115.parse(parsed_data)
489
- ```
490
-
491
- **Query Document Management:**
492
-
493
- Peddler provides a helper method for downloading query documents:
494
-
495
- ```ruby
496
- api = Peddler.data_kiosk.new(aws_region, access_token)
497
-
498
- # Download a query document by ID (v2023-11-15 schemas)
499
- document = api.download_query_document("amzn1.tortuga.3.abc123...")
500
-
501
- # Or pass a full URL
502
- document = api.download_query_document("https://...")
503
- ```
504
-
505
- **Type-Safe Response Parsing:**
506
-
507
- Each Data Kiosk schema version includes type-safe Structure classes that match the GraphQL response structure:
508
-
509
- ```ruby
510
- # Parse economics data
511
- response_data = JSON.parse(query_response_body)
512
- analytics = Peddler::DataKiosk::Economics20240315.parse(response_data)
513
-
514
- # Access typed attributes
515
- analytics.analytics_economics_2024_03_15.each do |record|
516
- puts "Sales: #{record.sales}"
517
- puts "Fees: #{record.fees}"
518
- puts "Net Proceeds: #{record.net_proceeds}"
519
- puts "Date Range: #{record.start_date} to #{record.end_date}"
520
- end
521
- ```
522
-
523
- **Query Examples by Schema:**
524
-
525
- ```ruby
526
- # Sales and Traffic by ASIN (2023-11-15)
527
- query_sales_asin = """
528
- query {
529
- salesAndTrafficByAsin(
530
- startDate: "2024-01-01",
531
- endDate: "2024-01-31",
532
- marketplaceIds: ["ATVPDKIKX0DER"]
533
- ) {
534
- data {
535
- startDate
536
- endDate
537
- parentAsin
538
- childAsin
539
- sku
540
- sales {
541
- orderedProductSales
542
- totalOrderItems
543
- unitsOrdered
544
- }
545
- traffic {
546
- pageViews
547
- pageViewsPercentage
548
- sessions
549
- sessionPercentage
550
- unitSessionPercentage
551
- }
552
- }
553
- }
554
- }
555
- """
556
-
557
- # Economics data (2024-03-15)
558
- query_economics = """
559
- query {
560
- analytics {
561
- economics {
562
- data {
563
- endDate
564
- startDate
565
- parentAsin
566
- sales {
567
- orderedProductSales
568
- netProductSales
569
- }
570
- fees {
571
- feeType
572
- chargeAmount
573
- }
574
- netProceeds {
575
- total
576
- perUnit
577
- }
578
- }
579
- }
580
- }
581
- }
582
- """
583
-
584
- # Vendor analytics (2024-09-30)
585
- query_vendor = """
586
- query {
587
- analytics {
588
- vendoranalytics {
589
- manufacturingView {
590
- startDate
591
- endDate
592
- metrics {
593
- costs
594
- traffic
595
- orders
596
- }
597
- }
598
- }
599
- }
600
- }
601
- """
602
- ```
603
-
604
- #### Communication and Customer Management APIs
605
-
606
- - **Customer Feedback API (2024-06-01)**: Analyze customer reviews and returns data at item and browse node levels
607
- - **Notifications API (v1)**: Subscribe to notifications for events like order updates
608
- - **Messaging API (v1)**: Send messages to customers
609
- - **Solicitations API (v1)**: Request customer reviews
610
-
611
- ```ruby
612
- # Customer Feedback API example
613
- api = Peddler.customer_feedback_2024_06_01.new(aws_region, access_token)
614
-
615
- # Get item review topics (most positive and negative)
616
- review_topics = api.get_item_review_topics(
617
- "B08N5WRWNW", # ASIN
618
- Marketplace.id("US"),
619
- "frequency" # Sort by frequency
620
- )
621
-
622
- # Get item review trends for past 6 months
623
- review_trends = api.get_item_review_trends(
624
- "B08N5WRWNW",
625
- Marketplace.id("US")
626
- )
627
-
628
- # Get browse node return topics
629
- return_topics = api.get_browse_node_return_topics(
630
- "123456789", # Browse node ID
631
- Marketplace.id("US")
632
- )
633
- ```
634
-
635
- ```ruby
636
- api = Peddler.notifications.new(aws_region, access_token)
637
- # Create destination
638
- destination = api.create_destination(
639
- name: "MyEventQueue",
640
- resourceSpecification: {
641
- sqs: { arn: "arn:aws:sqs:us-east-1:123456789012:MyQueue" }
642
- }
643
- )
644
- destination_id = destination.dig("payload", "destinationId")
645
-
646
- # Create subscription
647
- api.create_subscription(
648
- notificationType: "ANY_OFFER_CHANGED",
649
- destinationId: destination_id,
650
- payloadVersion: "1"
651
- )
652
-
653
- # For sandbox testing (requires grantless token)
654
- sandbox_api = Peddler.notifications.new(aws_region, grantless_access_token)
655
- sandbox_api = sandbox_api.sandbox
656
- # Get all destinations
657
- destinations = sandbox_api.get_destinations
658
-
659
- # Get specific subscription
660
- subscription = sandbox_api.get_subscription("LISTINGS_ITEM_ISSUES_CHANGE")
661
- ```
662
-
663
- **Parsing Notifications:**
664
-
665
- Once you receive notifications (via SQS or EventBridge), parse them with type-safe data classes:
666
-
667
- ```ruby
668
- # Parse notification from SQS message
669
- notification_json = JSON.parse(sqs_message.body)
670
- notification = Peddler::Notifications::AnyOfferChanged.parse(notification_json)
671
-
672
- # Type-safe access to notification data
673
- notification.notification_version # => "1.0"
674
- notification.notification_type # => "ANY_OFFER_CHANGED"
675
-
676
- # Access payload with autocomplete
677
- notification.payload.offers.each do |offer|
678
- puts "Seller: #{offer.seller_id}"
679
- puts "Price: #{offer.listing_price.amount} #{offer.listing_price.currency_code}"
680
- puts "Condition: #{offer.item_condition}"
681
- puts "Prime: #{offer.is_prime?}" if offer.respond_to?(:is_prime?)
682
- end
248
+ # Poll for completion and download document
683
249
  ```
684
-
685
250
  #### Vendor APIs
686
251
 
687
- APIs for vendors selling to Amazon:
688
-
689
- - **Vendor Orders API (v1)**: Retrieve purchase orders
690
- - **Vendor Direct Fulfillment Orders API (2021-12-28, v1)**: Manage direct fulfillment orders
691
- - **Vendor Direct Fulfillment Shipping API (2021-12-28, v1)**: Manage shipping for direct fulfillment
692
- - **Vendor Direct Fulfillment Payments API (v1)**: Process payments for direct fulfillment
693
- - **Vendor Direct Fulfillment Inventory API (v1)**: Manage inventory for direct fulfillment
694
- - **Vendor Direct Fulfillment Transactions API (2021-12-28, v1)**: Track transaction status
695
- - **Vendor Direct Fulfillment Sandbox Test Data API (2021-10-28)**: Generate test data in sandbox
696
- - **Vendor Shipments API (v1)**: Track vendor shipments
697
- - **Vendor Invoices API (v1)**: Submit and track invoices
698
- - **Vendor Transaction Status API (v1)**: Check transaction status
252
+ - **Vendor Orders API**: Retrieve purchase orders
253
+ - **Vendor Direct Fulfillment Orders API**: Manage direct fulfillment orders
254
+ - **Vendor Direct Fulfillment Shipping API**: Manage shipping for direct fulfillment
255
+ - **Vendor Direct Fulfillment Payments API**: Process payments for direct fulfillment
256
+ - **Vendor Direct Fulfillment Inventory API**: Manage inventory for direct fulfillment
257
+ - **Vendor Direct Fulfillment Transactions API**: Track transaction status
258
+ - **Vendor Direct Fulfillment Sandbox Test Data API**: Generate test data in sandbox
259
+ - **Vendor Shipments API**: Track vendor shipments
260
+ - **Vendor Invoices API**: Submit and track invoices
261
+ - **Vendor Transaction Status API**: Check transaction status
699
262
 
700
263
  ```ruby
701
264
  api = Peddler.vendor_orders.new(aws_region, access_token)
702
- orders = api.get_purchase_orders(
703
- limit: 10,
704
- createdAfter: "2023-01-01T00:00:00Z"
705
- ).parse
265
+ orders = api.get_purchase_orders(limit: 10, createdAfter: "2023-01-01T00:00:00Z").parse
706
266
  ```
707
267
 
708
268
  #### Authorization and Account Management APIs
709
269
 
710
- - **Application Management API (2023-11-30)**: Manage application authorization
711
- - **Tokens API (2021-03-01)**: Generate restricted data tokens for accessing PII
712
- - **Sellers API (v1)**: Get seller account information and marketplace participation
713
- - **Services API (v1)**: Manage seller services and subscriptions
714
- - **Seller Wallet API (2024-03-01)**: Manage seller financial accounts
715
- - **Application Integrations API (2024-04-01)**: Manage app integrations
716
- - **Vehicles API (2024-11-01)**: Manage vehicle data for automotive products
717
-
718
- ### Additional API Examples
719
-
720
- #### Product Pricing API
721
-
722
- ```ruby
723
- # Using Product Pricing v0
724
- api = Peddler.product_pricing_v0.new(aws_region, access_token)
725
-
726
- # Get pricing information for an ASIN
727
- pricing = api.get_pricing(
728
- Marketplace.id("US"),
729
- "Asin",
730
- asins: ["B08N5WRWNW"]
731
- )
732
-
733
- # Get competitive pricing for an ASIN
734
- competitive = api.get_competitive_pricing(
735
- Marketplace.id("US"),
736
- "Asin",
737
- asins: ["B08N5WRWNW"]
738
- )
739
-
740
- # Get offers for a specific item
741
- offers = api.get_item_offers(
742
- Marketplace.id("US"),
743
- "New",
744
- "B08N5WRWNW"
745
- )
746
-
747
- # Batch request for multiple items (2022-05-01 API)
748
- api = Peddler.product_pricing_2022_05_01.new(aws_region, access_token)
749
- batch_request = {
750
- requests: [
751
- {
752
- uri: "/products/pricing/2022-05-01/items/competitiveSummary",
753
- method: "GET",
754
- asin: "B08N5WRWNW",
755
- marketplaceId: Marketplace.id("US"),
756
- includedData: ["featuredBuyingOptions", "referencePrices", "lowestPricedOffers"]
757
- },
758
- # Additional items...
759
- ]
760
- }
761
- results = api.get_competitive_summary(batch_request)
762
- ```
763
-
764
- #### Listings Items API
765
-
766
- ```ruby
767
- api = Peddler.listings_items.new(aws_region, access_token)
768
-
769
- # Create or update a listing
770
- listing_result = api.put_listings_item(
771
- "SELLER_ID",
772
- "SKU123",
773
- Marketplace.id("US"),
774
- {
775
- productType: "PRODUCT",
776
- requirements: "LISTING_OFFER_ONLY",
777
- attributes: {
778
- merchant_suggested_asin: [{
779
- value: "B08N5WRWNW",
780
- marketplace_id: Marketplace.id("US")
781
- }],
782
- condition_type: [{
783
- value: "new_new",
784
- marketplace_id: Marketplace.id("US")
785
- }],
786
- # Additional attributes...
787
- }
788
- }
789
- )
270
+ - **Application Management API**: Manage application authorization
271
+ - **Tokens API**: Generate restricted data tokens for accessing PII
272
+ - **Sellers API**: Get seller account information and marketplace participation
273
+ - **Services API**: Manage seller services and subscriptions
274
+ - **Seller Wallet API**: Manage seller financial accounts
275
+ - **Application Integrations API**: Manage app integrations
276
+ - **Vehicles API**: Manage vehicle data for automotive products
790
277
 
791
- # Update specific listing elements with JSON Patch
792
- patch_result = api.patch_listings_item(
793
- "SELLER_ID",
794
- "SKU123",
795
- Marketplace.id("US"),
796
- {
797
- productType: "PRODUCT",
798
- patches: [
799
- {
800
- op: "replace",
801
- path: "/attributes/purchasable_offer",
802
- value: [{
803
- currency: "USD",
804
- our_price: [{
805
- schedule: [{
806
- value_with_tax: 39.99
807
- }]
808
- }]
809
- }]
810
- }
811
- ]
812
- }
813
- )
814
-
815
- # Get listing details
816
- listing = api.get_listings_item(
817
- "SELLER_ID",
818
- "SKU123",
819
- Marketplace.id("US"),
820
- included_data: "attributes,issues"
821
- )
278
+ ### Complex Workflows
822
279
 
823
- # Delete a listing
824
- api.delete_listings_item("SELLER_ID", "SKU123", Marketplace.id("US"))
825
- ```
280
+ Detailed workflows are available in test files with VCR cassettes:
826
281
 
827
- #### Listings Restrictions API
282
+ - **Feeds API**: [test/peddler/apis/feeds_2021_06_30_test.rb](test/peddler/apis/feeds_2021_06_30_test.rb)
283
+ - **Data Kiosk API**: [test/peddler/apis/data_kiosk_2023_11_15_test.rb](test/peddler/apis/data_kiosk_2023_11_15_test.rb)
284
+ - **Reports API**: [lib/peddler/apis/reports_2021_06_30.rb](lib/peddler/apis/reports_2021_06_30.rb) (YARD docs)
285
+ - **Notifications API**: [lib/peddler/notifications/](lib/peddler/notifications/) (type-safe parsing)
828
286
 
829
- ```ruby
830
- api = Peddler.listings_restrictions.new(aws_region, access_token)
831
-
832
- # Check restrictions for an ASIN
833
- restrictions = api.get_listings_restrictions(
834
- "B08N5WRWNW",
835
- "SELLER_ID",
836
- Marketplace.id("US"),
837
- condition_type: "new_new"
838
- )
839
- ```
287
+ For complete method signatures, see [sig/peddler/apis/](sig/peddler/apis/)
840
288
 
841
- #### Product Type Definitions API
842
-
843
- ```ruby
844
- api = Peddler.product_type_definitions.new(aws_region, access_token)
845
-
846
- # Get schema for a product type
847
- definition = api.get_definitions_product_type(
848
- "PRODUCT",
849
- Marketplace.id("US"),
850
- requirements: "LISTING_OFFER_ONLY"
851
- )
852
-
853
- # Download the JSON schema
854
- schema_url = definition.dig("schema", "link", "resource")
855
- json_schema = HTTP.get(schema_url).parse(:json)
856
- ```
857
-
858
- #### Reports API
859
-
860
- ```ruby
861
- api = Peddler.reports.new(aws_region, access_token)
862
-
863
- # Request a report
864
- report_response = api.create_report({
865
- "reportType" => "GET_MERCHANTS_LISTINGS_FYP_REPORT",
866
- "marketplaceIds" => Marketplace.ids("US")
867
- })
868
- report_id = report_response.dig("reportId")
869
-
870
- # Get report status
871
- report = api.get_report(report_id)
872
-
873
- # Get all reports of a specific type
874
- reports = api.get_reports(report_types: ["GET_MERCHANTS_LISTINGS_FYP_REPORT"])
875
-
876
- # Download a report document (using convenience helper)
877
- response = api.download_report_document("DOCUMENT_ID")
878
- # Process the downloaded report content from response.body...
879
- ```
880
-
881
- #### Understanding Report Types
882
-
883
- SP-API provides two different types of reports with different formats and APIs:
884
-
885
- **1. Modern JSON-Based Reports** (Recommended)
886
-
887
- These are structured analytics reports that return JSON data with defined schemas. Peddler provides type-safe data classes for these reports using the Structure gem.
888
-
889
- Examples:
890
- - Vendor Real-Time Inventory Report
891
- - Seller Sales and Traffic Report
892
- - Account Health Report
893
- - Vendor Forecasting Report
894
- - Customer Feedback Reports
895
-
896
- Location in Peddler: `lib/peddler/reports/` with generated Structure-based classes
897
-
898
- ```ruby
899
- # Example: Request and parse a vendor real-time inventory report
900
- api = Peddler.reports.new(aws_region, access_token)
901
-
902
- # Create report request
903
- report_response = api.create_report({
904
- "reportType" => "GET_VENDOR_REAL_TIME_INVENTORY_REPORT",
905
- "marketplaceIds" => [Marketplace.id("US")],
906
- "reportOptions" => {
907
- "reportPeriod" => "WEEK",
908
- "distributorView" => "MANUFACTURING",
909
- "sellingProgram" => "RETAIL",
910
- "startDate" => "2024-01-01",
911
- "endDate" => "2024-01-07"
912
- }
913
- })
914
-
915
- # Wait for report to be ready, then download
916
- report_id = report_response.dig("reportId")
917
- # ... check status until DONE ...
918
- document_id = api.get_report(report_id).dig("reportDocumentId")
919
-
920
- # Download and parse JSON report
921
- document = api.get_report_document(document_id)
922
- report_json = HTTP.get(document.dig("url")).parse(:json)
923
-
924
- # Use typed data classes
925
- report = Peddler::Reports::VendorRealTimeInventory::Report.new(report_json)
926
- report.report_data.each do |data|
927
- puts "ASIN: #{data.asin}, Inventory: #{data.highly_available_inventory}"
928
- end
929
- ```
930
-
931
- **2. Legacy Flat-File Reports** (Tab-Delimited)
932
-
933
- These are older reports that return tab-delimited text files (TSV format), often GZIP compressed. These require manual CSV parsing and do NOT have Structure-based data classes.
934
-
935
- Examples:
936
- - `GET_MERCHANT_LISTINGS_ALL_DATA`
937
- - `GET_FBA_MYI_UNSUPPRESSED_INVENTORY_DATA`
938
- - `GET_FLAT_FILE_ALL_ORDERS_DATA_BY_LAST_UPDATE_GENERAL`
939
-
940
- These must be parsed manually using Ruby's CSV library:
941
-
942
- ```ruby
943
- # Download flat-file report
944
- document = api.get_report_document(document_id)
945
- response = HTTP.get(document.dig("url"))
946
-
947
- # Handle GZIP compression if needed
948
- body = if document.dig("compressionAlgorithm") == "GZIP"
949
- Zlib::GzipReader.new(StringIO.new(response.body.to_s)).read
950
- else
951
- response.body.to_s
952
- end
953
-
954
- # Parse tab-delimited data
955
- csv_options = {
956
- col_sep: "\t",
957
- headers: true,
958
- quote_char: "\x00",
959
- encoding: "UTF-8"
960
- }
961
- CSV.parse(body, **csv_options) do |row|
962
- # Process each row as a hash
963
- puts "SKU: #{row['sku']}, ASIN: #{row['asin']}, Quantity: #{row['quantity']}"
964
- end
965
- ```
966
-
967
- For a complete list of report types and their formats, see the [Report Type Values documentation](https://developer-docs.amazon.com/sp-api/docs/report-type-values).
968
-
969
- #### Sellers API
970
-
971
- ```ruby
972
- api = Peddler.sellers.new(aws_region, access_token)
973
-
974
- # Get marketplace participations
975
- participations = api.get_marketplace_participations
976
- ```
977
-
978
- For a complete list of available APIs and their detailed documentation, refer to the [API models repository][swagger-models].
289
+ For a complete list of available APIs and their detailed documentation, refer to the [API models repository][openapi-models].
979
290
 
980
291
  ## Development
981
292
 
@@ -997,11 +308,13 @@ bundle exec rake generate
997
308
  bundle exec steep check --severity-level=hint
998
309
  ```
999
310
 
311
+ > AI Agents: See [llms.txt](llms.txt)
312
+
1000
313
  [build]: https://github.com/lineofflight/peddler/actions
1001
314
  [api-docs]: https://developer.amazonservices.com/sp-api-docs/overview
1002
315
  [register-as-developer]: https://developer-docs.amazon.com/sp-api/docs/registering-as-a-developer
1003
316
  [register-application]: https://developer-docs.amazon.com/sp-api/docs/registering-your-application
1004
- [swagger-models]: https://github.com/amzn/selling-partner-api-models
317
+ [openapi-models]: https://github.com/amzn/selling-partner-api-models
1005
318
  [api-samples]: https://github.com/amzn/selling-partner-api-samples
1006
319
  [view-credentials]: https://developer-docs.amazon.com/sp-api/docs/viewing-your-application-information-and-credentials
1007
320
  [authorization]: https://developer-docs.amazon.com/sp-api/docs/authorizing-selling-partner-api-applications