peddler 2.4.5 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +406 -134
  3. data/lib/peddler/access_token.rb +76 -0
  4. data/lib/peddler/api/amazon_warehousing_and_distribution_2024_05_09.rb +80 -0
  5. data/lib/peddler/api/aplus_content_2020_11_01.rb +208 -0
  6. data/lib/peddler/api/application_management_2023_11_30.rb +25 -0
  7. data/lib/peddler/api/catalog_items_2020_12_01.rb +70 -0
  8. data/lib/peddler/api/catalog_items_2022_04_01.rb +83 -0
  9. data/lib/peddler/api/catalog_items_v0.rb +90 -0
  10. data/lib/peddler/api/data_kiosk_2023_11_15.rb +92 -0
  11. data/lib/peddler/api/easy_ship_2022_03_23.rb +108 -0
  12. data/lib/peddler/api/fba_inbound_eligibility_v1.rb +36 -0
  13. data/lib/peddler/api/fba_inventory_v1.rb +106 -0
  14. data/lib/peddler/api/feeds_2021_06_30.rb +104 -0
  15. data/lib/peddler/api/finances_v0.rb +121 -0
  16. data/lib/peddler/api/fulfillment_inbound_2024_03_20.rb +660 -0
  17. data/lib/peddler/api/fulfillment_inbound_v0.rb +314 -0
  18. data/lib/peddler/api/fulfillment_outbound_2020_07_01.rb +222 -0
  19. data/lib/peddler/api/listings_items_2020_09_01.rb +84 -0
  20. data/lib/peddler/api/listings_items_2021_08_01.rb +154 -0
  21. data/lib/peddler/api/listings_restrictions_2021_08_01.rb +37 -0
  22. data/lib/peddler/api/merchant_fulfillment_v0.rb +64 -0
  23. data/lib/peddler/api/messaging_v1.rb +241 -0
  24. data/lib/peddler/api/notifications_v1.rb +114 -0
  25. data/lib/peddler/api/orders_v0.rb +264 -0
  26. data/lib/peddler/api/product_fees_v0.rb +69 -0
  27. data/lib/peddler/api/product_pricing_2022_05_01.rb +43 -0
  28. data/lib/peddler/api/product_pricing_v0.rb +144 -0
  29. data/lib/peddler/api/product_type_definitions_2020_09_01.rb +75 -0
  30. data/lib/peddler/api/replenishment_2022_11_07.rb +45 -0
  31. data/lib/peddler/api/reports_2021_06_30.rb +139 -0
  32. data/lib/peddler/api/sales_v1.rb +69 -0
  33. data/lib/peddler/api/sellers_v1.rb +33 -0
  34. data/lib/peddler/api/services_v1.rb +308 -0
  35. data/lib/peddler/api/shipment_invoicing_v0.rb +46 -0
  36. data/lib/peddler/api/shipping_v1.rb +107 -0
  37. data/lib/peddler/api/shipping_v2.rb +267 -0
  38. data/lib/peddler/api/solicitations_v1.rb +53 -0
  39. data/lib/peddler/api/supply_sources_2020_07_01.rb +82 -0
  40. data/lib/peddler/api/tokens_2021_03_01.rb +30 -0
  41. data/lib/peddler/api/uploads_2020_11_01.rb +40 -0
  42. data/lib/peddler/api/vendor_direct_fulfillment_inventory_v1.rb +24 -0
  43. data/lib/peddler/api/vendor_direct_fulfillment_orders_2021_12_28.rb +72 -0
  44. data/lib/peddler/api/vendor_direct_fulfillment_orders_v1.rb +72 -0
  45. data/lib/peddler/api/vendor_direct_fulfillment_payments_v1.rb +23 -0
  46. data/lib/peddler/api/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +35 -0
  47. data/lib/peddler/api/vendor_direct_fulfillment_shipping_2021_12_28.rb +177 -0
  48. data/lib/peddler/api/vendor_direct_fulfillment_shipping_v1.rb +165 -0
  49. data/lib/peddler/api/vendor_direct_fulfillment_transactions_2021_12_28.rb +24 -0
  50. data/lib/peddler/api/vendor_direct_fulfillment_transactions_v1.rb +24 -0
  51. data/lib/peddler/api/vendor_invoices_v1.rb +22 -0
  52. data/lib/peddler/api/vendor_orders_v1.rb +148 -0
  53. data/lib/peddler/api/vendor_shipments_v1.rb +120 -0
  54. data/lib/peddler/api/vendor_transaction_status_v1.rb +24 -0
  55. data/lib/peddler/api.rb +115 -0
  56. data/lib/peddler/error.rb +30 -0
  57. data/lib/peddler/region.rb +30 -0
  58. data/lib/peddler/version.rb +1 -1
  59. data/lib/peddler.rb +52 -1
  60. metadata +70 -80
  61. data/lib/mws/easy_ship/client.rb +0 -93
  62. data/lib/mws/easy_ship.rb +0 -3
  63. data/lib/mws/feeds/client.rb +0 -122
  64. data/lib/mws/feeds.rb +0 -3
  65. data/lib/mws/finances/client.rb +0 -82
  66. data/lib/mws/finances.rb +0 -3
  67. data/lib/mws/fulfillment_inbound_shipment/client.rb +0 -388
  68. data/lib/mws/fulfillment_inbound_shipment.rb +0 -3
  69. data/lib/mws/fulfillment_inventory/client.rb +0 -57
  70. data/lib/mws/fulfillment_inventory.rb +0 -3
  71. data/lib/mws/fulfillment_outbound_shipment/client.rb +0 -211
  72. data/lib/mws/fulfillment_outbound_shipment.rb +0 -3
  73. data/lib/mws/merchant_fulfillment/client.rb +0 -87
  74. data/lib/mws/merchant_fulfillment.rb +0 -3
  75. data/lib/mws/off_amazon_payments.rb +0 -3
  76. data/lib/mws/orders/client.rb +0 -120
  77. data/lib/mws/orders.rb +0 -3
  78. data/lib/mws/products/client.rb +0 -268
  79. data/lib/mws/products.rb +0 -3
  80. data/lib/mws/recommendations/client.rb +0 -72
  81. data/lib/mws/recommendations.rb +0 -3
  82. data/lib/mws/reports/client.rb +0 -236
  83. data/lib/mws/reports.rb +0 -3
  84. data/lib/mws/sellers/client.rb +0 -44
  85. data/lib/mws/sellers.rb +0 -3
  86. data/lib/mws/shipment_invoicing/client.rb +0 -74
  87. data/lib/mws/shipment_invoicing.rb +0 -3
  88. data/lib/mws/subscriptions/client.rb +0 -179
  89. data/lib/mws/subscriptions.rb +0 -3
  90. data/lib/mws.rb +0 -29
  91. data/lib/peddler/client.rb +0 -159
  92. data/lib/peddler/errors/builder.rb +0 -64
  93. data/lib/peddler/errors/class_generator.rb +0 -40
  94. data/lib/peddler/errors/error.rb +0 -45
  95. data/lib/peddler/errors/parser.rb +0 -28
  96. data/lib/peddler/flat_file_parser.rb +0 -56
  97. data/lib/peddler/headers.rb +0 -102
  98. data/lib/peddler/marketplace.rb +0 -79
  99. data/lib/peddler/operation.rb +0 -78
  100. data/lib/peddler/parser.rb +0 -33
  101. data/lib/peddler/structured_list.rb +0 -23
  102. data/lib/peddler/vcr_matcher.rb +0 -97
  103. data/lib/peddler/xml_parser.rb +0 -38
  104. data/lib/peddler/xml_response_parser.rb +0 -25
data/README.md CHANGED
@@ -1,244 +1,516 @@
1
1
  # Peddler
2
2
 
3
- [![Build](https://github.com/hakanensari/peddler/workflows/build/badge.svg)](https://github.com/hakanensari/peddler/actions)
4
- [![Maintainability](https://api.codeclimate.com/v1/badges/281e6176048f3c0a1ed3/maintainability)](https://codeclimate.com/github/hakanensari/peddler/maintainability)
5
- [![Test Coverage](https://api.codeclimate.com/v1/badges/281e6176048f3c0a1ed3/test_coverage)](https://codeclimate.com/github/hakanensari/peddler/test_coverage)
3
+ [![Build](https://github.com/hakanensari/peddler/workflows/build/badge.svg)][build]
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/281e6176048f3c0a1ed3/maintainability)][maintainability]
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/281e6176048f3c0a1ed3/test_coverage)][test-coverage]
6
6
 
7
- > :boom: Amazon is migrating to the newly-launched Selling Partner API (SP-API) and is no longer granting new users access to the MWS APIs. I hope to add support in Peddler in due course.
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
- **Peddler** is a Ruby interface to the [Amazon MWS API](https://developer.amazonservices.com/), a collection of web services that help Amazon sellers programmatically exchange data on their listings, orders, payments, reports, and more.
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.
10
10
 
11
- To use Amazon MWS, you must have an eligible seller account and [register as a developer](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Registering.html#DG_Registering__RegisteringAsADeveloper). You can then access your own selling account using its merchant ID—note that Amazon also refers to this as seller ID or merchant token in different places.
11
+ ![Peddler](https://github.com/hakanensari/peddler/blob/main/images/peddler.jpg?raw=true)
12
12
 
13
- Amazon has [multiple regions](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Endpoints.html). Each region requires application developers to register individually. Some MWS API sections may require additional authorisation from Amazon.
13
+ ## Installation
14
14
 
15
- ![Peddler](https://github.com/hakanensari/peddler/blob/main/images/peddler.jpg?raw=true)
15
+ Add this line to your Gemfile.
16
+
17
+ ```ruby
18
+ gem "peddler", "3.0.0.beta1"
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ ```shell
24
+ bundle install
25
+ ```
16
26
 
17
27
  ## Usage
18
28
 
29
+ Set your LWA credentials in your environment.
30
+
31
+ ```shell
32
+ export LWA_CLIENT_ID=<YOUR_CLIENT_ID>
33
+ export LWA_CLIENT_SECRET=<YOUR_CLIENT_SECRET>
34
+ ```
35
+
19
36
  Require the library.
20
37
 
21
38
  ```ruby
22
39
  require "peddler"
23
40
  ```
24
41
 
25
- A client requires the AWS credentials of the application developer. If you are working in a single MWS region, you can set them globally.
42
+ ### Authentication
26
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.
27
45
 
28
- ```bash
29
- export AWS_ACCESS_KEY_ID=YOUR_AWS_ACCESS_KEY_ID
30
- export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
46
+ ```ruby
47
+ access_token = Peddler::AccessToken.request(
48
+ refresh_token: "<REFRESH_TOKEN>",
49
+ )
31
50
  ```
32
51
 
33
- Now, create a client with the Amazon marketplace you signed up on and a merchant ID. Peddler provides a class for each API section under an eponymous namespace.
52
+ You can also request a token for grantless operations.
34
53
 
35
54
  ```ruby
36
- client = MWS.orders(marketplace: "ATVPDKIKX0DER",
37
- merchant_id: "123")
38
-
39
- # or a shorthand
40
- client = MWS.orders(marketplace: "US",
41
- merchant_id: "123")
55
+ access_token = Peddler::AccessToken.request(
56
+ scope: "sellingpartnerapi::notifications",
57
+ )
42
58
  ```
43
59
 
44
- If you are creating a [client for another seller](https://developer.amazonservices.com/gp/mws/faq.html#developForSeller), pass an MWS Auth Token as well.
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:
45
63
 
46
64
  ```ruby
47
- client = MWS.orders(marketplace: "ATVPDKIKX0DER",
48
- merchant_id: "123",
49
- auth_token: "123")
65
+ access_token = Peddler::AccessToken.request(
66
+ client_id: "<YOUR_CLIENT_ID>",
67
+ client_secret: "<YOUR_CLIENT_SECRET>",
68
+ refresh_token: "<REFRESH_TOKEN>",
69
+ )
50
70
  ```
51
71
 
52
- You won't be able to create a client for another seller if you are in different regions.
72
+ ### Throttling
73
+
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.
53
75
 
54
- If you are working with sellers across multiple regions, a single set of credentials will not be enough. In that case, do not use global environment variables and pass your AWS credentials when creating the client.
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:
55
77
 
56
78
  ```ruby
57
- client = MWS.orders(marketplace: "ATVPDKIKX0DER",
58
- merchant_id: "123",
59
- aws_access_key_id: "123",
60
- aws_secret_access_key: "123")
79
+ gem "http", github: "httprb/http"
61
80
  ```
62
81
 
63
- Once you have a client with valid credentials, you should be able to make requests to the API. Clients map operation names in a flat structure. Methods have positional arguments for required input and keyword arguments for optional parameters. Both method and argument names are underscored but otherwise identical to the names of the corresponding operations and parameters documented in the API.
64
-
65
- For instance, using the above MWS Orders client:
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.
66
83
 
67
84
  ```ruby
68
- response = client.list_orders('ATVPDKIKX0DER')
85
+ @api.rate_limit(5).get_item_offers_batch(...)
69
86
  ```
70
87
 
71
- ### Parser
88
+ This sets a custom rate limit of 5 requests per second for the requested operation.
89
+
90
+ ### The APIs
91
+
92
+ Peddler provides a class for each API version under an eponymous namespace. Below is a list of the more important APIs, along with brief descriptions and code examples to help you get started.
93
+
94
+ #### Catalog Items API (2022-04-01)
95
+
96
+ Provides programmatic access to Amazon's catalog data, such as item titles, descriptions, and other product details.
72
97
 
73
- Peddler wraps successful responses in a generic parser that handles both XML documents and flat files:
98
+ **Example:**
74
99
 
75
100
  ```ruby
76
- response = client.get_service_status
77
- response.parse # will return a Hash object
78
- response.dig('Status') # delegates to Hash#dig
101
+ client = Peddler::API::CatalogItems20220401.new("<AWS_REGION>", "<ACCESS_TOKEN>")
102
+ response = client.get_catalog_item(
103
+ marketplaceIds: ["ATVPDKIKX0DER"],
104
+ asin: "B08N5WRWNW"
105
+ )
106
+ items = response.parse.dig("items")
79
107
  ```
80
108
 
81
- You can swap this with a purpose-built parser.
109
+ #### Orders API (v0)
110
+
111
+ Allows you to retrieve order information, including order details, buyer information, and order items.
112
+
113
+ **Example:**
82
114
 
83
115
  ```ruby
84
- MWS::Orders::Client.parser = MyParser
116
+ client = Peddler::API::OrdersV0.new("<AWS_REGION>", "<ACCESS_TOKEN>")
117
+ response = client.get_orders(
118
+ marketplaceIds: ["ATVPDKIKX0DER"],
119
+ createdAfter: "2023-01-01T00:00:00Z"
120
+ )
121
+ orders = response.parse.dig("orders")
85
122
  ```
86
123
 
87
- For a sample implementation, see my [MWS Orders](https://github.com/hakanensari/mws-orders) library.
88
-
89
- ### Throttling
124
+ #### Feeds API (2021-06-30)
90
125
 
91
- Amazon limits the number of requests you can submit to some operations in a given amount of time. When you hit a limit, your request throws a `Peddler::Errors::RequestThrottled` error.
126
+ Enables you to upload data to Amazon for updating listings, prices, inventory, and more.
92
127
 
93
- You will want to exit or back off exponentially and retry if you hit this error.
128
+ **Example:**
94
129
 
95
130
  ```ruby
96
- begin
97
- client.throttled_method
98
- rescue Peddler::Errors::RequestThrottled
99
- back_off_exponentially
100
- retry
101
- end
131
+ client = Peddler::API::Feeds20210630.new("<AWS_REGION>", "<ACCESS_TOKEN>")
132
+ # Create a feed document to get an upload URL
133
+ response = client.create_feed_document(
134
+ contentType: "text/xml; charset=UTF-8"
135
+ )
136
+ feed_document_id = response.parse["feedDocumentId"]
137
+ upload_url = response.parse["url"]
138
+
139
+ # Upload the feed content to the provided URL
140
+ feed_content = File.read("inventory_update.xml")
141
+ client.upload_feed_document(upload_url, feed_content)
142
+
143
+ # Create the feed
144
+ response = client.create_feed(
145
+ feedType: "POST_INVENTORY_AVAILABILITY_DATA",
146
+ marketplaceIds: ["ATVPDKIKX0DER"],
147
+ inputFeedDocumentId: feed_document_id
148
+ )
149
+ feed_id = response.parse["feedId"]
102
150
  ```
103
151
 
104
- Some API sections also have an hourly request quota in addition to the numerical request quota. When you hit this quota, your request throws a `Peddler::Errors::QuotaExceeded` error.
152
+ #### Reports API (2021-06-30)
105
153
 
106
- You can introspect your quota usage on the parsed response:
154
+ Allows you to request and download various reports, such as order and inventory reports.
107
155
 
108
- ```ruby
109
- response = client.method_with_quota
110
- puts response.mws_quota_remaining
111
- # 150
156
+ **Example:**
112
157
 
113
- begin
114
- client.method_with_quota
115
- rescue Peddler::Errors::QuotaExceeded => error
116
- puts error.response.mws_quota_remaining
117
- # 0
118
- end
158
+ ```ruby
159
+ client = Peddler::API::Reports20210630.new("<AWS_REGION>", "<ACCESS_TOKEN>")
160
+ response = client.create_report(
161
+ reportType: "GET_FLAT_FILE_OPEN_LISTINGS_DATA",
162
+ marketplaceIds: ["ATVPDKIKX0DER"]
163
+ )
164
+ report_id = response.parse["reportId"]
119
165
  ```
120
166
 
121
- Read [tips on how to avoid throttling](https://docs.developer.amazonservices.com/en_US/dev_guide/DG_Throttling.html).
167
+ #### Listings Items API (2021-08-01)
122
168
 
123
- ### Debugging
169
+ Enables you to manage your product listings on Amazon, including creating, updating, and deleting listings.
124
170
 
125
- If you are having trouble with a request, read the [Amazon documentation](https://developer.amazonservices.com/gp/mws/docs.html). [Peddler's source](https://www.rubydoc.info/github/hakanensari/peddler) also links individual operations to their corresponding entries in the Amazon docs.
171
+ **Example:**
126
172
 
127
- Note that some optional keywords have default values.
173
+ ```ruby
174
+ client = Peddler::API::ListingsItems20210801.new("<AWS_REGION>", "<ACCESS_TOKEN>")
175
+ response = client.put_listings_item(
176
+ "<SELLER_ID>",
177
+ "SKU123",
178
+ "ATVPDKIKX0DER",
179
+ body: {
180
+ productType: "PRODUCT",
181
+ requirements: "LISTING",
182
+ attributes: {
183
+ title: [{ value: "New Product Title" }],
184
+ description: [{ value: "Product description goes here." }],
185
+ bullet_point: [{ value: "Feature 1" }, { value: "Feature 2" }],
186
+ manufacturer: [{ value: "Your Brand" }]
187
+ }
188
+ }
189
+ )
190
+ result = response.parse
191
+ ```
128
192
 
129
- To introspect requests, set the `EXCON_DEBUG` environment variable to `1` or similar truthy value. Peddler will then log request and response internals to stdout.
193
+ #### Notifications API (v1)
130
194
 
131
- If you contact Amazon MWS support, they will ask you for the **RequestId** and **Timestamp** of affected requests.
195
+ Allows you to subscribe to notifications for specific events like order status updates or feed processing statuses.
196
+
197
+ **Example:**
132
198
 
133
199
  ```ruby
134
- response = client.problem_method
135
- puts response.mws_request_id
136
- puts response.mws_timestamp
200
+ client = Peddler::API::NotificationsV1.new("<AWS_REGION>", "<ACCESS_TOKEN>")
201
+ # Create a destination
202
+ response = client.create_destination(
203
+ name: "MySQSQueue",
204
+ resourceSpecification: {
205
+ sqs: {
206
+ arn: "arn:aws:sqs:us-east-1:123456789012:MyQueue"
207
+ }
208
+ }
209
+ )
210
+ destination_id = response.parse["destinationId"]
211
+
212
+ # Create a subscription
213
+ response = client.create_subscription(
214
+ notificationType: "ANY_OFFER_CHANGED",
215
+ destinationId: destination_id
216
+ )
217
+ subscription = response.parse
137
218
  ```
138
219
 
139
- You can access the same attributes on `error.response`. See <a href="#throttling">above example</a>.
140
-
141
- ## The APIs
220
+ #### Product Fees API (v0)
142
221
 
143
- ### Easy Ship
222
+ Provides information about fees that may be charged for selling products on Amazon.
144
223
 
145
- With the Easy Ship API, you can build applications that help sellers in India manage and ship their Amazon Easy Ship orders. Your Amazon Easy Ship applications can get available pickup slots; schedule, reschedule, and cancel pickups; and print labels, invoices, and warranties.
224
+ **Example:**
146
225
 
147
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/easy_ship/EasyShip_Overview.html)
148
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/EasyShip/Client)
226
+ ```ruby
227
+ client = Peddler::API::ProductFeesV0.new("<AWS_REGION>", "<ACCESS_TOKEN>")
228
+ response = client.get_my_fees_estimate_for_sku(
229
+ sellerId: "<YOUR_SELLER_ID>",
230
+ sku: "SKU123",
231
+ body: {
232
+ FeesEstimateRequest: {
233
+ MarketplaceId: "ATVPDKIKX0DER",
234
+ IsAmazonFulfilled: true,
235
+ PriceToEstimateFees: {
236
+ ListingPrice: {
237
+ CurrencyCode: "USD",
238
+ Amount: 25.00
239
+ }
240
+ }
241
+ }
242
+ }
243
+ )
244
+ fees_estimate = response.parse
245
+ ```
149
246
 
150
- ### Feeds
247
+ #### Fulfillment Outbound API (2020-07-01)
151
248
 
152
- The MWS Feeds API lets you upload inventory and order data to Amazon. You can also use this API to get information about the processing of feeds.
249
+ Allows you to create and manage fulfillment orders using Amazon's fulfillment network.
153
250
 
154
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/feeds/Feeds_Overview.html)
155
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Feeds/Client)
156
- - [XML schema docs](https://sellercentral.amazon.com/gp/help/help-page.html?itemID=1611)
251
+ **Example:**
157
252
 
158
- ### Finances
253
+ ```ruby
254
+ client = Peddler::API::FulfillmentOutbound20200701.new("<AWS_REGION>", "<ACCESS_TOKEN>")
255
+ response = client.create_fulfillment_order(
256
+ body: {
257
+ sellerFulfillmentOrderId: "ORDER123",
258
+ displayableOrderId: "ORDER123",
259
+ displayableOrderDate: Time.now.iso8601,
260
+ displayableOrderComment: "Thank you for your order!",
261
+ shippingSpeedCategory: "Standard",
262
+ destinationAddress: {
263
+ name: "John Doe",
264
+ addressLine1: "123 Main St",
265
+ city: "Anytown",
266
+ stateOrRegion: "NY",
267
+ postalCode: "12345",
268
+ countryCode: "US"
269
+ },
270
+ items: [
271
+ {
272
+ sellerSku: "SKU123",
273
+ sellerFulfillmentOrderItemId: "ITEM123",
274
+ quantity: 1
275
+ }
276
+ ]
277
+ }
278
+ )
279
+ result = response.parse
280
+ ```
159
281
 
160
- The MWS Finances API enables you to obtain financial information relevant to your business with Amazon. You can obtain financial events for a given order, financial event group, or date range without having to wait until a statement period closes. You can also obtain financial event groups for a given date range.
282
+ #### Merchant Fulfillment API (v0)
161
283
 
162
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/finances/Finances_Overview.html)
163
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Finances/Client)
284
+ Allows you to create shipping labels for orders using Amazon's negotiated shipping rates.
164
285
 
165
- ### Fulfillment Inbound Shipment
286
+ **Example:**
166
287
 
167
- With the MWS Fulfillment Inbound Shipment API, you can create and update inbound shipments of inventory in the Amazon Fulfillment Network. You can also also request lists of inbound shipments or inbound shipment items based on criteria that you specify.
288
+ ```ruby
289
+ client = Peddler::API::MerchantFulfillmentV0.new("<AWS_REGION>", "<ACCESS_TOKEN>")
290
+ response = client.get_eligible_shipping_services(
291
+ body: {
292
+ shipmentRequestDetails: {
293
+ amazonOrderId: "ORDER123",
294
+ itemList: [
295
+ {
296
+ orderItemId: "ITEM123",
297
+ quantity: 1
298
+ }
299
+ ],
300
+ shipFromAddress: {
301
+ name: "Your Company",
302
+ addressLine1: "123 Warehouse Ave",
303
+ city: "Anytown",
304
+ stateOrRegion: "NY",
305
+ postalCode: "12345",
306
+ countryCode: "US"
307
+ },
308
+ packageDimensions: {
309
+ length: 10,
310
+ width: 5,
311
+ height: 8,
312
+ unit: "INCHES"
313
+ },
314
+ weight: {
315
+ value: 2,
316
+ unit: "POUNDS"
317
+ },
318
+ shippingServiceOptions: {
319
+ deliveryExperience: "DELIVERY_CONFIRMATION_WITHOUT_SIGNATURE",
320
+ carrierWillPickUp: false
321
+ }
322
+ }
323
+ }
324
+ )
325
+ shipping_services = response.parse["shippingServiceList"]
326
+ ```
168
327
 
169
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/fba_inbound/FBAInbound_Overview.html)
170
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/FulfillmentInboundShipment/Client)
328
+ #### Vendor Orders API (2021-12-29)
171
329
 
172
- ### Fulfillment Inventory
330
+ Allows vendors to retrieve purchase orders and order details from Amazon.
173
331
 
174
- The MWS Fulfillment Inventory API can help you stay up-to-date on the availability of your inventory in the Amazon Fulfillment Network. The Fulfillment Inventory API reports real-time availability information for your Amazon Fulfillment Network inventory regardless of whether you are selling your inventory on Amazon's retail web site or through other retail channels.
332
+ **Example:**
175
333
 
176
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/fba_inventory/FBAInventory_Overview.html)
177
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/FulfillmentInventory/Client)
334
+ ```ruby
335
+ client = Peddler::API::VendorOrders20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
336
+ response = client.get_purchase_orders(
337
+ shipToPartyId: "<PARTY_ID>",
338
+ limit: 10,
339
+ createdAfter: "2023-01-01T00:00:00Z"
340
+ )
341
+ purchase_orders = response.parse["purchaseOrders"]
342
+ ```
178
343
 
179
- ### Fulfillment Outbound Shipment
344
+ #### Vendor Direct Fulfillment Shipping API (2021-12-28)
180
345
 
181
- The MWS Fulfillment Outbound Shipment API enables you to fulfill orders placed through channels other than Amazon's retail web site, using your inventory in the Amazon Fulfillment Network. You can request previews of potential fulfillment orders that return estimated shipping fees and shipping dates based on shipping speed. You can get detailed item-level, shipment-level, and order-level information for any existing fulfillment order that you specify. You can also request lists of existing fulfillment orders based on when they were fulfilled and by the fulfillment method associated with them.
346
+ Enables vendors to manage shipping labels and shipping information for direct fulfillment orders.
182
347
 
183
- Support for creating and cancelling fulfillment orders has been implemented, but the rest of the API is not supported yet.
348
+ **Example:**
184
349
 
185
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/fba_outbound/FBAOutbound_Overview.html)
186
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/FulfillmentOutboundShipment/Client)
350
+ ```ruby
351
+ client = Peddler::API::VendorDirectFulfillmentShipping20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
352
+ response = client.get_packing_slip(
353
+ purchaseOrderNumber: "PO123456789"
354
+ )
355
+ packing_slip = response.parse
356
+ ```
187
357
 
188
- ### Merchant Fulfillment
358
+ #### Vendor Direct Fulfillment Orders API (2021-12-28)
189
359
 
190
- The Merchant Fulfillment API provides programmatic access to Amazon’s fulfillment shipping services for sellers, including competitive rates with Amazon-partnered carriers. Sellers can find out what shipping services are available by submitting information about a proposed fulfillment shipment, such as package size and weight; shipment origin and destination; and delivery date requirements. Sellers can choose from the shipping service options returned by Amazon, and then receive shipping labels for fulfilling their orders.
360
+ Allows vendors to receive orders for direct fulfillment and provide shipment confirmations.
191
361
 
192
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/merch_fulfill/MerchFulfill_Overview.html)
193
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/MerchantFulfillment/Client)
362
+ **Example:**
194
363
 
195
- ### Orders
364
+ ```ruby
365
+ client = Peddler::API::VendorDirectFulfillmentOrders20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
366
+ response = client.get_orders(
367
+ createdAfter: "2023-01-01T00:00:00Z",
368
+ limit: 10
369
+ )
370
+ orders = response.parse["orders"]
371
+ ```
196
372
 
197
- With the MWS Orders API, you can list orders created or updated during a time frame you specify or retrieve information about specific orders.
373
+ #### Vendor Direct Fulfillment Inventory API (2021-12-28)
198
374
 
199
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/orders-2013-09-01/Orders_Overview.html)
200
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Orders/Client)
375
+ Enables vendors to update inventory levels for direct fulfillment items.
201
376
 
202
- ### Products
377
+ **Example:**
203
378
 
204
- The MWS Products API helps you get information to match your products to existing product listings on Amazon Marketplace websites and to make sourcing and pricing decisions for listing those products on Amazon Marketplace websites.
379
+ ```ruby
380
+ client = Peddler::API::VendorDirectFulfillmentInventory20211228.new("<AWS_REGION>", "<ACCESS_TOKEN>")
381
+ response = client.submit_inventory_update(
382
+ body: {
383
+ inventory: [
384
+ {
385
+ sellingParty: {
386
+ partyId: "<PARTY_ID>"
387
+ },
388
+ warehouseId: "<WAREHOUSE_ID>",
389
+ items: [
390
+ {
391
+ buyerProductIdentifier: "B08N5WRWNW",
392
+ availableQuantity: {
393
+ amount: 100,
394
+ unitOfMeasure: "Each"
395
+ }
396
+ }
397
+ ]
398
+ }
399
+ ]
400
+ }
401
+ )
402
+ result = response.parse
403
+ ```
205
404
 
206
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/products/Products_Overview.html)
207
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Products/Client)
405
+ #### Shipping API (v2)
208
406
 
209
- ### Recommendations
407
+ Provides functionalities for purchasing shipping labels and tracking shipments.
210
408
 
211
- The Recommendations API enables you to programmatically retrieve Amazon Selling Coach recommendations by recommendation category. A recommendation is an actionable, timely, and personalized opportunity to increase your sales and performance.
409
+ **Example:**
212
410
 
213
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/recommendations/Recommendations_Overview.html)
214
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Recommendations/Client)
411
+ ```ruby
412
+ client = Peddler::API::ShippingV2.new("<AWS_REGION>", "<ACCESS_TOKEN>")
413
+ response = client.purchase_shipment(
414
+ body: {
415
+ clientReferenceId: "CLIENT_REF_123",
416
+ shipTo: {
417
+ name: "John Doe",
418
+ addressLine1: "123 Main St",
419
+ city: "Anytown",
420
+ stateOrRegion: "NY",
421
+ postalCode: "12345",
422
+ countryCode: "US"
423
+ },
424
+ shipFrom: {
425
+ name: "Your Company",
426
+ addressLine1: "123 Warehouse Ave",
427
+ city: "Anytown",
428
+ stateOrRegion: "NY",
429
+ postalCode: "12345",
430
+ countryCode: "US"
431
+ },
432
+ packages: [
433
+ {
434
+ dimensions: {
435
+ length: 10,
436
+ width: 5,
437
+ height: 8,
438
+ unit: "IN"
439
+ },
440
+ weight: {
441
+ value: 2,
442
+ unit: "LB"
443
+ }
444
+ }
445
+ ],
446
+ serviceType: "Standard"
447
+ }
448
+ )
449
+ shipment = response.parse
450
+ ```
215
451
 
216
- ### Reports
452
+ #### Token API (2021-03-01)
217
453
 
218
- The Reports API lets you request reports about your inventory and orders.
454
+ Allows you to create restricted data tokens to access personally identifiable information (PII) in specific API calls.
219
455
 
220
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/reports/Reports_Overview.html)
221
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Reports/Client)
456
+ **Example:**
222
457
 
223
- ### Sellers
458
+ ```ruby
459
+ client = Peddler::API::Tokens20210301.new("<AWS_REGION>", "<ACCESS_TOKEN>")
460
+ response = client.create_restricted_data_token(
461
+ body: {
462
+ restrictedResources: [
463
+ {
464
+ method: "GET",
465
+ path: "/orders/v0/orders/123-1234567-1234567",
466
+ dataElements: ["buyerInfo", "shippingAddress"]
467
+ }
468
+ ]
469
+ }
470
+ )
471
+ restricted_data_token = response.parse["restrictedDataToken"]
472
+
473
+ # 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(
476
+ orderId: "123-1234567-1234567"
477
+ )
478
+ order_details = response.parse
479
+ ```
224
480
 
225
- The Sellers API lets sellers retrieve information about their seller account, such as the marketplaces they participate in.
481
+ #### Finances API (v0)
226
482
 
227
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_Overview.html)
228
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Sellers/Client)
483
+ Provides information about financial events for your seller account, such as order payments, refunds, and fees.
229
484
 
230
- ### Shipment Invoicing
485
+ **Example:**
231
486
 
232
- With the Shipment Invoicing API section (in conjunction with the FBAOutboundShipmentStatus notification), you can integrate invoicing into Amazon’s shipping process for a seller’s Fulfillment by Amazon (FBA) orders.
487
+ ```ruby
488
+ client = Peddler::API::FinancesV0.new
489
+ response = client.list_financial_events(
490
+ postedAfter: "2023-01-01T00:00:00Z",
491
+ maxResultsPerPage: 100
492
+ )
493
+ financial_events = response.parse["FinancialEvents"]
494
+ ```
233
495
 
234
- This functionality is available only in the Brazil marketplace.
496
+ #### Sellers API (V1)
235
497
 
236
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/shipment_invoicing/ShipmentInvoicing_Overview.html)
237
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/ShipmentInvoicing/Client)
498
+ Provides information about seller's marketplaces and participation status.
238
499
 
239
- ### Subscriptions
500
+ **Example:**
240
501
 
241
- The Amazon MWS Subscriptions API section enables you to subscribe to receive notifications that are relevant to your business with Amazon. With the operations in the Subscriptions API section, you can register to receive important information from Amazon without having to poll the Amazon MWS service. Instead, the information is sent directly to you when an event occurs to which you are subscribed.
502
+ ```ruby
503
+ client = Peddler::API::SellersV1.new
504
+ response = client.get_marketplace_participations
505
+ participations = response.parse["payload"]
506
+ ```
242
507
 
243
- - [Amazon references](https://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_Overview.html)
244
- - [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Subscriptions/Client)
508
+ [build]: https://github.com/hakanensari/peddler/actions
509
+ [maintainability]: https://codeclimate.com/github/hakanensari/peddler/maintainability
510
+ [test-coverage]: https://codeclimate.com/github/hakanensari/peddler/test_coverage
511
+ [docs-overview]: https://developer.amazonservices.com/sp-api-docs/overview
512
+ [register-as-developer]: https://developer-docs.amazon.com/sp-api/docs/registering-as-a-developer
513
+ [register-application]: https://developer-docs.amazon.com/sp-api/docs/registering-your-application
514
+ [view-credentials]: https://developer-docs.amazon.com/sp-api/docs/viewing-your-application-information-and-credentials
515
+ [authorization]: https://developer-docs.amazon.com/sp-api/docs/authorizing-selling-partner-api-applications
516
+ [httprb]: https://github.com/httprb/http