peddler 2.4.5 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +402 -140
- data/lib/peddler/api/amazon_warehousing_and_distribution_2024_05_09.rb +92 -0
- data/lib/peddler/api/aplus_content_2020_11_01.rb +246 -0
- data/lib/peddler/api/application_integrations_2024_04_01.rb +56 -0
- data/lib/peddler/api/application_management_2023_11_30.rb +35 -0
- data/lib/peddler/api/catalog_items_2020_12_01.rb +81 -0
- data/lib/peddler/api/catalog_items_2022_04_01.rb +93 -0
- data/lib/peddler/api/catalog_items_v0.rb +103 -0
- data/lib/peddler/api/data_kiosk_2023_11_15.rb +108 -0
- data/lib/peddler/api/easy_ship_2022_03_23.rb +127 -0
- data/lib/peddler/api/fba_inbound_eligibility_v1.rb +44 -0
- data/lib/peddler/api/fba_inventory_v1.rb +122 -0
- data/lib/peddler/api/feeds_2021_06_30.rb +122 -0
- data/lib/peddler/api/finances_2024_06_19.rb +50 -0
- data/lib/peddler/api/finances_v0.rb +148 -0
- data/lib/peddler/api/fulfillment_inbound_2024_03_20.rb +759 -0
- data/lib/peddler/api/fulfillment_inbound_v0.rb +352 -0
- data/lib/peddler/api/fulfillment_outbound_2020_07_01.rb +259 -0
- data/lib/peddler/api/invoices_2024_06_19.rb +180 -0
- data/lib/peddler/api/listings_items_2020_09_01.rb +95 -0
- data/lib/peddler/api/listings_items_2021_08_01.rb +170 -0
- data/lib/peddler/api/listings_restrictions_2021_08_01.rb +47 -0
- data/lib/peddler/api/merchant_fulfillment_v0.rb +80 -0
- data/lib/peddler/api/messaging_v1.rb +273 -0
- data/lib/peddler/api/notifications_v1.rb +145 -0
- data/lib/peddler/api/orders_v0.rb +279 -0
- data/lib/peddler/api/product_fees_v0.rb +77 -0
- data/lib/peddler/api/product_pricing_2022_05_01.rb +54 -0
- data/lib/peddler/api/product_pricing_v0.rb +162 -0
- data/lib/peddler/api/product_type_definitions_2020_09_01.rb +86 -0
- data/lib/peddler/api/replenishment_2022_11_07.rb +57 -0
- data/lib/peddler/api/reports_2021_06_30.rb +163 -0
- data/lib/peddler/api/sales_v1.rb +77 -0
- data/lib/peddler/api/sellers_v1.rb +45 -0
- data/lib/peddler/api/services_v1.rb +348 -0
- data/lib/peddler/api/shipment_invoicing_v0.rb +59 -0
- data/lib/peddler/api/shipping_v1.rb +132 -0
- data/lib/peddler/api/shipping_v2.rb +319 -0
- data/lib/peddler/api/solicitations_v1.rb +63 -0
- data/lib/peddler/api/supply_sources_2020_07_01.rb +100 -0
- data/lib/peddler/api/tokens_2021_03_01.rb +38 -0
- data/lib/peddler/api/uploads_2020_11_01.rb +50 -0
- data/lib/peddler/api/vendor_direct_fulfillment_inventory_v1.rb +32 -0
- data/lib/peddler/api/vendor_direct_fulfillment_orders_2021_12_28.rb +84 -0
- data/lib/peddler/api/vendor_direct_fulfillment_orders_v1.rb +84 -0
- data/lib/peddler/api/vendor_direct_fulfillment_payments_v1.rb +31 -0
- data/lib/peddler/api/vendor_direct_fulfillment_sandbox_test_data_2021_10_28.rb +45 -0
- data/lib/peddler/api/vendor_direct_fulfillment_shipping_2021_12_28.rb +203 -0
- data/lib/peddler/api/vendor_direct_fulfillment_shipping_v1.rb +189 -0
- data/lib/peddler/api/vendor_direct_fulfillment_transactions_2021_12_28.rb +32 -0
- data/lib/peddler/api/vendor_direct_fulfillment_transactions_v1.rb +32 -0
- data/lib/peddler/api/vendor_invoices_v1.rb +30 -0
- data/lib/peddler/api/vendor_orders_v1.rb +159 -0
- data/lib/peddler/api/vendor_shipments_v1.rb +132 -0
- data/lib/peddler/api/vendor_transaction_status_v1.rb +33 -0
- data/lib/peddler/api.rb +138 -0
- data/lib/peddler/endpoint.rb +51 -0
- data/lib/peddler/error.rb +31 -0
- data/lib/peddler/marketplace.rb +38 -68
- data/lib/peddler/token.rb +70 -0
- data/lib/peddler/version.rb +1 -1
- data/lib/peddler.rb +56 -1
- metadata +74 -80
- data/lib/mws/easy_ship/client.rb +0 -93
- data/lib/mws/easy_ship.rb +0 -3
- data/lib/mws/feeds/client.rb +0 -122
- data/lib/mws/feeds.rb +0 -3
- data/lib/mws/finances/client.rb +0 -82
- data/lib/mws/finances.rb +0 -3
- data/lib/mws/fulfillment_inbound_shipment/client.rb +0 -388
- data/lib/mws/fulfillment_inbound_shipment.rb +0 -3
- data/lib/mws/fulfillment_inventory/client.rb +0 -57
- data/lib/mws/fulfillment_inventory.rb +0 -3
- data/lib/mws/fulfillment_outbound_shipment/client.rb +0 -211
- data/lib/mws/fulfillment_outbound_shipment.rb +0 -3
- data/lib/mws/merchant_fulfillment/client.rb +0 -87
- data/lib/mws/merchant_fulfillment.rb +0 -3
- data/lib/mws/off_amazon_payments.rb +0 -3
- data/lib/mws/orders/client.rb +0 -120
- data/lib/mws/orders.rb +0 -3
- data/lib/mws/products/client.rb +0 -268
- data/lib/mws/products.rb +0 -3
- data/lib/mws/recommendations/client.rb +0 -72
- data/lib/mws/recommendations.rb +0 -3
- data/lib/mws/reports/client.rb +0 -236
- data/lib/mws/reports.rb +0 -3
- data/lib/mws/sellers/client.rb +0 -44
- data/lib/mws/sellers.rb +0 -3
- data/lib/mws/shipment_invoicing/client.rb +0 -74
- data/lib/mws/shipment_invoicing.rb +0 -3
- data/lib/mws/subscriptions/client.rb +0 -179
- data/lib/mws/subscriptions.rb +0 -3
- data/lib/mws.rb +0 -29
- data/lib/peddler/client.rb +0 -159
- data/lib/peddler/errors/builder.rb +0 -64
- data/lib/peddler/errors/class_generator.rb +0 -40
- data/lib/peddler/errors/error.rb +0 -45
- data/lib/peddler/errors/parser.rb +0 -28
- data/lib/peddler/flat_file_parser.rb +0 -56
- data/lib/peddler/headers.rb +0 -102
- data/lib/peddler/operation.rb +0 -78
- data/lib/peddler/parser.rb +0 -33
- data/lib/peddler/structured_list.rb +0 -23
- data/lib/peddler/vcr_matcher.rb +0 -97
- data/lib/peddler/xml_parser.rb +0 -38
- data/lib/peddler/xml_response_parser.rb +0 -25
data/README.md
CHANGED
@@ -1,244 +1,506 @@
|
|
1
1
|
# Peddler
|
2
2
|
|
3
|
-
[![Build](https://github.com/hakanensari/peddler/workflows/build/badge.svg)]
|
4
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/281e6176048f3c0a1ed3/maintainability)]
|
5
|
-
[![Test Coverage](https://api.codeclimate.com/v1/badges/281e6176048f3c0a1ed3/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
|
-
|
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
|
-
|
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.
|
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.
|
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.
|
14
10
|
|
15
11
|
![Peddler](https://github.com/hakanensari/peddler/blob/main/images/peddler.jpg?raw=true)
|
16
12
|
|
17
|
-
##
|
13
|
+
## Installation
|
18
14
|
|
19
|
-
|
15
|
+
Add this line to your Gemfile.
|
20
16
|
|
21
17
|
```ruby
|
22
|
-
|
18
|
+
gem "peddler", "3.0.0.beta1"
|
23
19
|
```
|
24
20
|
|
25
|
-
|
26
|
-
|
21
|
+
And then execute:
|
27
22
|
|
28
|
-
```
|
29
|
-
|
30
|
-
export AWS_SECRET_ACCESS_KEY=YOUR_AWS_SECRET_ACCESS_KEY
|
23
|
+
```shell
|
24
|
+
bundle install
|
31
25
|
```
|
32
26
|
|
33
|
-
|
27
|
+
## Usage
|
34
28
|
|
35
|
-
|
36
|
-
client = MWS.orders(marketplace: "ATVPDKIKX0DER",
|
37
|
-
merchant_id: "123")
|
29
|
+
Set your LWA credentials in your environment.
|
38
30
|
|
39
|
-
|
40
|
-
|
41
|
-
|
31
|
+
```shell
|
32
|
+
export LWA_CLIENT_ID=<YOUR_CLIENT_ID>
|
33
|
+
export LWA_CLIENT_SECRET=<YOUR_CLIENT_SECRET>
|
42
34
|
```
|
43
35
|
|
44
|
-
|
36
|
+
Require the library.
|
45
37
|
|
46
38
|
```ruby
|
47
|
-
|
48
|
-
merchant_id: "123",
|
49
|
-
auth_token: "123")
|
39
|
+
require "peddler"
|
50
40
|
```
|
51
41
|
|
52
|
-
|
42
|
+
### Authorization
|
53
43
|
|
54
|
-
|
44
|
+
A seller or vendor [provides you a refresh token][authorization] to access their data on Amazon.
|
55
45
|
|
56
46
|
```ruby
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
aws_secret_access_key: "123")
|
47
|
+
refresh_token = Peddled::Token.request(
|
48
|
+
code: "<AUTHORIZATION_CODE>"
|
49
|
+
).parse["refresh_token"]
|
61
50
|
```
|
62
51
|
|
63
|
-
|
64
|
-
|
65
|
-
For instance, using the above MWS Orders client:
|
52
|
+
You use this to generate a temporary access token to authenticate individual API requests.
|
66
53
|
|
67
54
|
```ruby
|
68
|
-
|
55
|
+
access_token = Peddler::Token.request(
|
56
|
+
refresh_token: "<REFRESH_TOKEN>",
|
57
|
+
).parse["access_token"]
|
69
58
|
```
|
70
59
|
|
71
|
-
|
72
|
-
|
73
|
-
Peddler wraps successful responses in a generic parser that handles both XML documents and flat files:
|
60
|
+
Similarly, you can request a token for grantless operations.
|
74
61
|
|
75
62
|
```ruby
|
76
|
-
|
77
|
-
|
78
|
-
|
63
|
+
access_token = Peddler::Token.request(
|
64
|
+
scope: "sellingpartnerapi::notifications",
|
65
|
+
).parse["access_token"]
|
79
66
|
```
|
80
67
|
|
81
|
-
|
68
|
+
If you haven’t set your LWA credentials as environment variables, pass them directly when requesting the token.
|
82
69
|
|
83
70
|
```ruby
|
84
|
-
|
71
|
+
access_token = Peddler::Token.request(
|
72
|
+
client_id: "<YOUR_CLIENT_ID>",
|
73
|
+
client_secret: "<YOUR_CLIENT_SECRET>",
|
74
|
+
refresh_token: "<REFRESH_TOKEN>",
|
75
|
+
).parse["access_token"]
|
85
76
|
```
|
86
77
|
|
87
|
-
|
88
|
-
|
89
|
-
### Throttling
|
78
|
+
Access tokens are valid for one hour. To optimize performance, cache the token and reuse across calls.
|
90
79
|
|
91
|
-
|
92
|
-
|
93
|
-
You will want to exit or back off exponentially and retry if you hit this error.
|
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:
|
94
81
|
|
95
82
|
```ruby
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
101
93
|
end
|
102
94
|
```
|
103
95
|
|
104
|
-
|
96
|
+
### Rate limiting
|
105
97
|
|
106
|
-
|
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.
|
107
99
|
|
108
|
-
|
109
|
-
response = client.method_with_quota
|
110
|
-
puts response.mws_quota_remaining
|
111
|
-
# 150
|
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.
|
112
101
|
|
113
|
-
|
114
|
-
client.method_with_quota
|
115
|
-
rescue Peddler::Errors::QuotaExceeded => error
|
116
|
-
puts error.response.mws_quota_remaining
|
117
|
-
# 0
|
118
|
-
end
|
119
|
-
```
|
102
|
+
### The APIs
|
120
103
|
|
121
|
-
|
104
|
+
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.
|
122
105
|
|
123
|
-
|
106
|
+
#### Catalog Items API (2022-04-01)
|
124
107
|
|
125
|
-
|
108
|
+
Provides programmatic access to Amazon's catalog data, such as item titles, descriptions, and other product details.
|
126
109
|
|
127
|
-
|
110
|
+
```ruby
|
111
|
+
api = Peddler.catalog_items_2022_04_01(aws_region, access_token)
|
112
|
+
response = api.get_catalog_item(
|
113
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
114
|
+
asin: "B08N5WRWNW"
|
115
|
+
)
|
116
|
+
items = response.parse.dig("items")
|
117
|
+
```
|
128
118
|
|
129
|
-
|
119
|
+
#### Orders API (v0)
|
130
120
|
|
131
|
-
|
121
|
+
Allows you to retrieve order information, including order details, buyer information, and order items.
|
132
122
|
|
133
123
|
```ruby
|
134
|
-
|
135
|
-
|
136
|
-
|
124
|
+
api = Peddler.orders_v0(aws_region, access_token)
|
125
|
+
response = api.get_orders(
|
126
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
127
|
+
createdAfter: "2023-01-01T00:00:00Z"
|
128
|
+
)
|
129
|
+
response.parse.dig("orders")
|
137
130
|
```
|
138
131
|
|
139
|
-
|
132
|
+
#### Feeds API (2021-06-30)
|
140
133
|
|
141
|
-
|
134
|
+
Enables you to upload data to Amazon for updating listings, prices, inventory, and more.
|
142
135
|
|
143
|
-
|
136
|
+
```ruby
|
137
|
+
api = Peddler.feeds_2021_06_30(aws_region, access_token)
|
138
|
+
|
139
|
+
# Create a feed document to get an upload URL
|
140
|
+
response = api.create_feed_document(
|
141
|
+
contentType: "text/xml; charset=UTF-8"
|
142
|
+
)
|
143
|
+
feed_document_id = response.parse["feedDocumentId"]
|
144
|
+
upload_url = response.parse["url"]
|
145
|
+
|
146
|
+
# Upload the feed content to the provided URL
|
147
|
+
feed_content = File.read("inventory_update.xml")
|
148
|
+
api.upload_feed_document(upload_url, feed_content)
|
149
|
+
|
150
|
+
# Create the feed
|
151
|
+
response = api.create_feed(
|
152
|
+
feedType: "POST_INVENTORY_AVAILABILITY_DATA",
|
153
|
+
marketplaceIds: ["ATVPDKIKX0DER"],
|
154
|
+
inputFeedDocumentId: feed_document_id
|
155
|
+
)
|
156
|
+
response.parse["feedId"]
|
157
|
+
```
|
144
158
|
|
145
|
-
|
159
|
+
#### Reports API (2021-06-30)
|
146
160
|
|
147
|
-
|
148
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/EasyShip/Client)
|
161
|
+
Allows you to request and download various reports, such as order and inventory reports.
|
149
162
|
|
150
|
-
|
163
|
+
```ruby
|
164
|
+
api = Peddler.reports_2021_06_30(aws_region, access_token)
|
165
|
+
response = api.create_report(
|
166
|
+
reportType: "GET_FLAT_FILE_OPEN_LISTINGS_DATA",
|
167
|
+
marketplaceIds: ["ATVPDKIKX0DER"]
|
168
|
+
)
|
169
|
+
response.parse["reportId"]
|
170
|
+
```
|
151
171
|
|
152
|
-
|
172
|
+
#### Listings Items API (2021-08-01)
|
153
173
|
|
154
|
-
|
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)
|
174
|
+
Enables you to manage your product listings on Amazon, including creating, updating, and deleting listings.
|
157
175
|
|
158
|
-
|
176
|
+
```ruby
|
177
|
+
api = Peddler.listings_items_2021_08_01(aws_region, access_token)
|
178
|
+
response = api.put_listings_item(
|
179
|
+
"<SELLER_ID>",
|
180
|
+
"SKU123",
|
181
|
+
"ATVPDKIKX0DER",
|
182
|
+
body: {
|
183
|
+
productType: "PRODUCT",
|
184
|
+
requirements: "LISTING",
|
185
|
+
attributes: {
|
186
|
+
title: [{ value: "New Product Title" }],
|
187
|
+
description: [{ value: "Product description goes here." }],
|
188
|
+
bullet_point: [{ value: "Feature 1" }, { value: "Feature 2" }],
|
189
|
+
manufacturer: [{ value: "Your Brand" }]
|
190
|
+
}
|
191
|
+
}
|
192
|
+
)
|
193
|
+
response.parse
|
194
|
+
```
|
159
195
|
|
160
|
-
|
196
|
+
#### Notifications API (v1)
|
161
197
|
|
162
|
-
|
163
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Finances/Client)
|
198
|
+
Allows you to subscribe to notifications for specific events like order status updates or feed processing statuses.
|
164
199
|
|
165
|
-
|
200
|
+
```ruby
|
201
|
+
api = Peddler.notifications_v1(aws_region, access_token)
|
202
|
+
# Create a destination
|
203
|
+
response = api.create_destination(
|
204
|
+
name: "MySQSQueue",
|
205
|
+
resourceSpecification: {
|
206
|
+
sqs: {
|
207
|
+
arn: "arn:aws:sqs:us-east-1:123456789012:MyQueue"
|
208
|
+
}
|
209
|
+
}
|
210
|
+
)
|
211
|
+
destination_id = response.parse["destinationId"]
|
212
|
+
|
213
|
+
# Create a subscription
|
214
|
+
response = api.create_subscription(
|
215
|
+
notificationType: "ANY_OFFER_CHANGED",
|
216
|
+
destinationId: destination_id
|
217
|
+
)
|
218
|
+
subscription = response.parse
|
219
|
+
```
|
166
220
|
|
167
|
-
|
221
|
+
#### Product Fees API (v0)
|
168
222
|
|
169
|
-
|
170
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/FulfillmentInboundShipment/Client)
|
223
|
+
Provides information about fees that may be charged for selling products on Amazon.
|
171
224
|
|
172
|
-
|
225
|
+
```ruby
|
226
|
+
api = Peddler.product_fees_v0(aws_region, access_token)
|
227
|
+
response = api.get_my_fees_estimate_for_sku(
|
228
|
+
sellerId: "<YOUR_SELLER_ID>",
|
229
|
+
sku: "SKU123",
|
230
|
+
body: {
|
231
|
+
FeesEstimateRequest: {
|
232
|
+
MarketplaceId: "ATVPDKIKX0DER",
|
233
|
+
IsAmazonFulfilled: true,
|
234
|
+
PriceToEstimateFees: {
|
235
|
+
ListingPrice: {
|
236
|
+
CurrencyCode: "USD",
|
237
|
+
Amount: 25.00
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
)
|
243
|
+
fees_estimate = response.parse
|
244
|
+
```
|
173
245
|
|
174
|
-
|
246
|
+
#### Fulfillment Outbound API (2020-07-01)
|
175
247
|
|
176
|
-
|
177
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/FulfillmentInventory/Client)
|
248
|
+
Allows you to create and manage fulfillment orders using Amazon's fulfillment network.
|
178
249
|
|
179
|
-
|
250
|
+
```ruby
|
251
|
+
api = Peddler.fulfillment_outbound_2020_07_01(aws_region, access_token)
|
252
|
+
response = api.create_fulfillment_order(
|
253
|
+
body: {
|
254
|
+
sellerFulfillmentOrderId: "ORDER123",
|
255
|
+
displayableOrderId: "ORDER123",
|
256
|
+
displayableOrderDate: Time.now.iso8601,
|
257
|
+
displayableOrderComment: "Thank you for your order!",
|
258
|
+
shippingSpeedCategory: "Standard",
|
259
|
+
destinationAddress: {
|
260
|
+
name: "John Doe",
|
261
|
+
addressLine1: "123 Main St",
|
262
|
+
city: "Anytown",
|
263
|
+
stateOrRegion: "NY",
|
264
|
+
postalCode: "12345",
|
265
|
+
countryCode: "US"
|
266
|
+
},
|
267
|
+
items: [
|
268
|
+
{
|
269
|
+
sellerSku: "SKU123",
|
270
|
+
sellerFulfillmentOrderItemId: "ITEM123",
|
271
|
+
quantity: 1
|
272
|
+
}
|
273
|
+
]
|
274
|
+
}
|
275
|
+
)
|
276
|
+
response.parse
|
277
|
+
```
|
180
278
|
|
181
|
-
|
279
|
+
#### Merchant Fulfillment API (v0)
|
182
280
|
|
183
|
-
|
281
|
+
Allows you to create shipping labels for orders using Amazon's negotiated shipping rates.
|
184
282
|
|
185
|
-
|
186
|
-
|
283
|
+
```ruby
|
284
|
+
api = Peddler.merchant_fulfillment_v0(aws_region, access_token)
|
285
|
+
response = api.get_eligible_shipping_services(
|
286
|
+
body: {
|
287
|
+
shipmentRequestDetails: {
|
288
|
+
amazonOrderId: "ORDER123",
|
289
|
+
itemList: [
|
290
|
+
{
|
291
|
+
orderItemId: "ITEM123",
|
292
|
+
quantity: 1
|
293
|
+
}
|
294
|
+
],
|
295
|
+
shipFromAddress: {
|
296
|
+
name: "Your Company",
|
297
|
+
addressLine1: "123 Warehouse Ave",
|
298
|
+
city: "Anytown",
|
299
|
+
stateOrRegion: "NY",
|
300
|
+
postalCode: "12345",
|
301
|
+
countryCode: "US"
|
302
|
+
},
|
303
|
+
packageDimensions: {
|
304
|
+
length: 10,
|
305
|
+
width: 5,
|
306
|
+
height: 8,
|
307
|
+
unit: "INCHES"
|
308
|
+
},
|
309
|
+
weight: {
|
310
|
+
value: 2,
|
311
|
+
unit: "POUNDS"
|
312
|
+
},
|
313
|
+
shippingServiceOptions: {
|
314
|
+
deliveryExperience: "DELIVERY_CONFIRMATION_WITHOUT_SIGNATURE",
|
315
|
+
carrierWillPickUp: false
|
316
|
+
}
|
317
|
+
}
|
318
|
+
}
|
319
|
+
)
|
320
|
+
shipping_services = response.parse["shippingServiceList"]
|
321
|
+
```
|
187
322
|
|
188
|
-
|
323
|
+
#### Vendor Orders API (2021-12-29)
|
189
324
|
|
190
|
-
|
325
|
+
Allows vendors to retrieve purchase orders and order details from Amazon.
|
191
326
|
|
192
|
-
|
193
|
-
|
327
|
+
```ruby
|
328
|
+
api = Peddler.vendor_orders_2021_12_28(aws_region, access_token)
|
329
|
+
response = api.get_purchase_orders(
|
330
|
+
shipToPartyId: "<PARTY_ID>",
|
331
|
+
limit: 10,
|
332
|
+
createdAfter: "2023-01-01T00:00:00Z"
|
333
|
+
)
|
334
|
+
purchase_orders = response.parse["purchaseOrders"]
|
335
|
+
```
|
194
336
|
|
195
|
-
|
337
|
+
#### Vendor Direct Fulfillment Shipping API (2021-12-28)
|
196
338
|
|
197
|
-
|
339
|
+
Enables vendors to manage shipping labels and shipping information for direct fulfillment orders.
|
198
340
|
|
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)
|
201
341
|
|
202
|
-
|
342
|
+
```ruby
|
343
|
+
api = Peddler.vendor_direct_fulfillment_shipping_2021_12_28(aws_region, access_token)
|
344
|
+
response = api.get_packing_slip(
|
345
|
+
purchaseOrderNumber: "PO123456789"
|
346
|
+
)
|
347
|
+
response.parse
|
348
|
+
```
|
203
349
|
|
204
|
-
|
350
|
+
#### Vendor Direct Fulfillment Orders API (2021-12-28)
|
205
351
|
|
206
|
-
|
207
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Products/Client)
|
352
|
+
Allows vendors to receive orders for direct fulfillment and provide shipment confirmations.
|
208
353
|
|
209
|
-
### Recommendations
|
210
354
|
|
211
|
-
|
355
|
+
```ruby
|
356
|
+
api = Peddler.vendor_direct_fulfillment_orders_2021_12_28(aws_region, access_token)
|
357
|
+
response = api.get_orders(
|
358
|
+
createdAfter: "2023-01-01T00:00:00Z",
|
359
|
+
limit: 10
|
360
|
+
)
|
361
|
+
response.parse["orders"]
|
362
|
+
```
|
212
363
|
|
213
|
-
|
214
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/Recommendations/Client)
|
364
|
+
#### Vendor Direct Fulfillment Inventory API (2021-12-28)
|
215
365
|
|
216
|
-
|
366
|
+
Enables vendors to update inventory levels for direct fulfillment items.
|
217
367
|
|
218
|
-
|
368
|
+
```ruby
|
369
|
+
api = Peddler.vendor_direct_fulfillment_inventory_2021_12_28(aws_region, access_token)
|
370
|
+
response = api.submit_inventory_update(
|
371
|
+
body: {
|
372
|
+
inventory: [
|
373
|
+
{
|
374
|
+
sellingParty: {
|
375
|
+
partyId: "<PARTY_ID>"
|
376
|
+
},
|
377
|
+
warehouseId: "<WAREHOUSE_ID>",
|
378
|
+
items: [
|
379
|
+
{
|
380
|
+
buyerProductIdentifier: "B08N5WRWNW",
|
381
|
+
availableQuantity: {
|
382
|
+
amount: 100,
|
383
|
+
unitOfMeasure: "Each"
|
384
|
+
}
|
385
|
+
}
|
386
|
+
]
|
387
|
+
}
|
388
|
+
]
|
389
|
+
}
|
390
|
+
)
|
391
|
+
response.parse
|
392
|
+
```
|
393
|
+
|
394
|
+
#### Shipping API (v2)
|
219
395
|
|
220
|
-
|
221
|
-
|
396
|
+
Provides functionalities for purchasing shipping labels and tracking shipments.
|
397
|
+
|
398
|
+
```ruby
|
399
|
+
api = Peddler.shipping_v2(aws_region, access_token)
|
400
|
+
response = api.purchase_shipment(
|
401
|
+
body: {
|
402
|
+
clientReferenceId: "CLIENT_REF_123",
|
403
|
+
shipTo: {
|
404
|
+
name: "John Doe",
|
405
|
+
addressLine1: "123 Main St",
|
406
|
+
city: "Anytown",
|
407
|
+
stateOrRegion: "NY",
|
408
|
+
postalCode: "12345",
|
409
|
+
countryCode: "US"
|
410
|
+
},
|
411
|
+
shipFrom: {
|
412
|
+
name: "Your Company",
|
413
|
+
addressLine1: "123 Warehouse Ave",
|
414
|
+
city: "Anytown",
|
415
|
+
stateOrRegion: "NY",
|
416
|
+
postalCode: "12345",
|
417
|
+
countryCode: "US"
|
418
|
+
},
|
419
|
+
packages: [
|
420
|
+
{
|
421
|
+
dimensions: {
|
422
|
+
length: 10,
|
423
|
+
width: 5,
|
424
|
+
height: 8,
|
425
|
+
unit: "IN"
|
426
|
+
},
|
427
|
+
weight: {
|
428
|
+
value: 2,
|
429
|
+
unit: "LB"
|
430
|
+
}
|
431
|
+
}
|
432
|
+
],
|
433
|
+
serviceType: "Standard"
|
434
|
+
}
|
435
|
+
)
|
436
|
+
response.parse
|
437
|
+
```
|
222
438
|
|
223
|
-
|
439
|
+
#### Token API (2021-03-01)
|
224
440
|
|
225
|
-
|
441
|
+
Allows you to create restricted data tokens to access personally identifiable information (PII) in specific API calls.
|
226
442
|
|
227
|
-
|
228
|
-
|
443
|
+
```ruby
|
444
|
+
api = Peddler.tokens_2021_03_01(aws_region, access_token)
|
445
|
+
response = api.create_restricted_data_token(
|
446
|
+
body: {
|
447
|
+
restrictedResources: [
|
448
|
+
{
|
449
|
+
method: "GET",
|
450
|
+
path: "/orders/v0/orders/123-1234567-1234567",
|
451
|
+
dataElements: ["buyerInfo", "shippingAddress"]
|
452
|
+
}
|
453
|
+
]
|
454
|
+
}
|
455
|
+
)
|
456
|
+
restricted_data_token = response.parse["restrictedDataToken"]
|
457
|
+
|
458
|
+
# Use the token in subsequent API calls
|
459
|
+
orders_api = Peddler.orders_2021_12_01("<AWS_REGION>", restricted_data_token)
|
460
|
+
response = orders_api.get_order(
|
461
|
+
orderId: "123-1234567-1234567"
|
462
|
+
)
|
463
|
+
response.parse
|
464
|
+
```
|
229
465
|
|
230
|
-
|
466
|
+
#### Finances API (v0)
|
231
467
|
|
232
|
-
|
468
|
+
Provides information about financial events for your seller account, such as order payments, refunds, and fees.
|
233
469
|
|
234
|
-
|
470
|
+
```ruby
|
471
|
+
api = Peddler.finances_v0(aws_region, access_token)
|
472
|
+
response = api.list_financial_events(
|
473
|
+
postedAfter: "2023-01-01T00:00:00Z",
|
474
|
+
maxResultsPerPage: 100
|
475
|
+
)
|
476
|
+
response.parse
|
477
|
+
```
|
235
478
|
|
236
|
-
|
237
|
-
- [Peddler API docs](https://www.rubydoc.info/github/hakanensari/peddler/MWS/ShipmentInvoicing/Client)
|
479
|
+
#### Sellers API (V1)
|
238
480
|
|
239
|
-
|
481
|
+
Provides information about seller's marketplaces and participation status.
|
240
482
|
|
241
|
-
|
483
|
+
```ruby
|
484
|
+
api = Peddler.sellers_v1(aws_region, access_token)
|
485
|
+
response = api.get_marketplace_participations
|
486
|
+
response.parse
|
487
|
+
```
|
242
488
|
|
243
|
-
|
244
|
-
|
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
|
+
|
496
|
+
[build]: https://github.com/hakanensari/peddler/actions
|
497
|
+
[maintainability]: https://codeclimate.com/github/hakanensari/peddler/maintainability
|
498
|
+
[test-coverage]: https://codeclimate.com/github/hakanensari/peddler/test_coverage
|
499
|
+
[docs-overview]: https://developer.amazonservices.com/sp-api-docs/overview
|
500
|
+
[register-as-developer]: https://developer-docs.amazon.com/sp-api/docs/registering-as-a-developer
|
501
|
+
[register-application]: https://developer-docs.amazon.com/sp-api/docs/registering-your-application
|
502
|
+
[view-credentials]: https://developer-docs.amazon.com/sp-api/docs/viewing-your-application-information-and-credentials
|
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
|
505
|
+
[httprb]: https://github.com/httprb/http
|
506
|
+
[patches]: https://github.com/bizon/selling-partner-api-sdk/tree/master/codegen/patches
|