amazon_spapi/apis/
easy_ship_2022_03_23.rs

1/*
2 * Selling Partner API for Easy Ship
3 *
4 * Use the Selling Partner API for Easy Ship to build applications for sellers to manage and ship Amazon Easy Ship orders. With this API, you can get available time slots, schedule and reschedule Easy Ship orders, and print shipping labels, invoices, and warranties. To review the differences in Easy Ship operations by marketplace, refer to [Marketplace support](https://developer-docs.amazon.com/sp-api/docs/easyship-api-v2022-03-23-use-case-guide#marketplace-support).
5 *
6 * The version of the OpenAPI document: 2022-03-23
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_scheduled_package`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateScheduledPackageError {
22    Status400(models::easy_ship_2022_03_23::ErrorList),
23    Status401(models::easy_ship_2022_03_23::ErrorList),
24    Status403(models::easy_ship_2022_03_23::ErrorList),
25    Status404(models::easy_ship_2022_03_23::ErrorList),
26    Status413(models::easy_ship_2022_03_23::ErrorList),
27    Status415(models::easy_ship_2022_03_23::ErrorList),
28    Status429(models::easy_ship_2022_03_23::ErrorList),
29    Status500(models::easy_ship_2022_03_23::ErrorList),
30    Status503(models::easy_ship_2022_03_23::ErrorList),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`create_scheduled_package_bulk`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateScheduledPackageBulkError {
38    Status400(models::easy_ship_2022_03_23::ErrorList),
39    Status401(models::easy_ship_2022_03_23::ErrorList),
40    Status403(models::easy_ship_2022_03_23::ErrorList),
41    Status404(models::easy_ship_2022_03_23::ErrorList),
42    Status429(models::easy_ship_2022_03_23::ErrorList),
43    Status413(models::easy_ship_2022_03_23::ErrorList),
44    Status415(models::easy_ship_2022_03_23::ErrorList),
45    Status500(models::easy_ship_2022_03_23::ErrorList),
46    Status503(models::easy_ship_2022_03_23::ErrorList),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`get_scheduled_package`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum GetScheduledPackageError {
54    Status400(models::easy_ship_2022_03_23::ErrorList),
55    Status401(models::easy_ship_2022_03_23::ErrorList),
56    Status403(models::easy_ship_2022_03_23::ErrorList),
57    Status404(models::easy_ship_2022_03_23::ErrorList),
58    Status413(models::easy_ship_2022_03_23::ErrorList),
59    Status415(models::easy_ship_2022_03_23::ErrorList),
60    Status429(models::easy_ship_2022_03_23::ErrorList),
61    Status500(models::easy_ship_2022_03_23::ErrorList),
62    Status503(models::easy_ship_2022_03_23::ErrorList),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`list_handover_slots`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ListHandoverSlotsError {
70    Status400(models::easy_ship_2022_03_23::ErrorList),
71    Status401(models::easy_ship_2022_03_23::ErrorList),
72    Status403(models::easy_ship_2022_03_23::ErrorList),
73    Status404(models::easy_ship_2022_03_23::ErrorList),
74    Status413(models::easy_ship_2022_03_23::ErrorList),
75    Status415(models::easy_ship_2022_03_23::ErrorList),
76    Status429(models::easy_ship_2022_03_23::ErrorList),
77    Status500(models::easy_ship_2022_03_23::ErrorList),
78    Status503(models::easy_ship_2022_03_23::ErrorList),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`update_scheduled_packages`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum UpdateScheduledPackagesError {
86    Status400(models::easy_ship_2022_03_23::ErrorList),
87    Status401(models::easy_ship_2022_03_23::ErrorList),
88    Status403(models::easy_ship_2022_03_23::ErrorList),
89    Status404(models::easy_ship_2022_03_23::ErrorList),
90    Status413(models::easy_ship_2022_03_23::ErrorList),
91    Status415(models::easy_ship_2022_03_23::ErrorList),
92    Status429(models::easy_ship_2022_03_23::ErrorList),
93    Status500(models::easy_ship_2022_03_23::ErrorList),
94    Status503(models::easy_ship_2022_03_23::ErrorList),
95    UnknownValue(serde_json::Value),
96}
97
98
99/// Schedules an Easy Ship order and returns the scheduled package information.  This operation does the following:  *  Specifies the time slot and handover method for the order to be scheduled for delivery.  * Updates the Easy Ship order status.  * Generates a shipping label and an invoice. Calling `createScheduledPackage` also generates a warranty document if you specify a `SerialNumber` value. To get these documents, see [How to get invoice, shipping label, and warranty documents](doc:easyship-api-v2022-03-23-use-case-guide).  * Shows the status of Easy Ship orders when you call the `getOrders` operation of the Selling Partner API for Orders and examine the `EasyShipShipmentStatus` property in the response body.  See the **Shipping Label**, **Invoice**, and **Warranty** columns in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table) to see which documents are supported in each marketplace.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
100pub async fn create_scheduled_package(configuration: &configuration::Configuration, create_scheduled_package_request: models::easy_ship_2022_03_23::CreateScheduledPackageRequest) -> Result<models::easy_ship_2022_03_23::Package, Error<CreateScheduledPackageError>> {
101    // add a prefix to parameters to efficiently prevent name collisions
102    let p_create_scheduled_package_request = create_scheduled_package_request;
103
104    let uri_str = format!("{}/easyShip/2022-03-23/package", configuration.base_path);
105    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
106
107    if let Some(ref user_agent) = configuration.user_agent {
108        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
109    }
110    req_builder = req_builder.json(&p_create_scheduled_package_request);
111
112    let req = req_builder.build()?;
113    let resp = configuration.client.execute(req).await?;
114
115    let status = resp.status();
116    let content_type = resp
117        .headers()
118        .get("content-type")
119        .and_then(|v| v.to_str().ok())
120        .unwrap_or("application/octet-stream");
121    let content_type = super::ContentType::from(content_type);
122
123    if !status.is_client_error() && !status.is_server_error() {
124        let content = resp.text().await?;
125        match content_type {
126            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
127            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::easy_ship_2022_03_23::Package`"))),
128            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::easy_ship_2022_03_23::Package`")))),
129        }
130    } else {
131        let content = resp.text().await?;
132        let entity: Option<CreateScheduledPackageError> = serde_json::from_str(&content).ok();
133        Err(Error::ResponseError(ResponseContent { status, content, entity }))
134    }
135}
136
137/// This operation automatically schedules a time slot for all the `amazonOrderId`s given as input, generating the associated shipping labels, along with other compliance documents according to the marketplace (refer to the [marketplace document support table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table)).  Developers calling this operation may optionally assign a `packageDetails` object, allowing them to input a preferred time slot for each order in their request. In this case, Amazon will try to schedule the respective packages using their optional settings. On the other hand, *i.e.*, if the time slot is not provided, Amazon will then pick the earliest time slot possible.   Regarding the shipping label's file format, external developers are able to choose between PDF or ZPL, and Amazon will create the label accordingly.  This operation returns an array composed of the scheduled packages, and a short-lived URL pointing to a zip file containing the generated shipping labels and the other documents enabled for your marketplace. If at least an order couldn't be scheduled, then Amazon adds the `rejectedOrders` list into the response, which contains an entry for each order we couldn't process. Each entry is composed of an error message describing the reason of the failure, so that sellers can take action.  The table below displays the supported request and burst maximum rates:  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
138pub async fn create_scheduled_package_bulk(configuration: &configuration::Configuration, create_scheduled_packages_request: models::easy_ship_2022_03_23::CreateScheduledPackagesRequest) -> Result<models::easy_ship_2022_03_23::CreateScheduledPackagesResponse, Error<CreateScheduledPackageBulkError>> {
139    // add a prefix to parameters to efficiently prevent name collisions
140    let p_create_scheduled_packages_request = create_scheduled_packages_request;
141
142    let uri_str = format!("{}/easyShip/2022-03-23/packages/bulk", configuration.base_path);
143    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
144
145    if let Some(ref user_agent) = configuration.user_agent {
146        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
147    }
148    req_builder = req_builder.json(&p_create_scheduled_packages_request);
149
150    let req = req_builder.build()?;
151    let resp = configuration.client.execute(req).await?;
152
153    let status = resp.status();
154    let content_type = resp
155        .headers()
156        .get("content-type")
157        .and_then(|v| v.to_str().ok())
158        .unwrap_or("application/octet-stream");
159    let content_type = super::ContentType::from(content_type);
160
161    if !status.is_client_error() && !status.is_server_error() {
162        let content = resp.text().await?;
163        match content_type {
164            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
165            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::easy_ship_2022_03_23::CreateScheduledPackagesResponse`"))),
166            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::easy_ship_2022_03_23::CreateScheduledPackagesResponse`")))),
167        }
168    } else {
169        let content = resp.text().await?;
170        let entity: Option<CreateScheduledPackageBulkError> = serde_json::from_str(&content).ok();
171        Err(Error::ResponseError(ResponseContent { status, content, entity }))
172    }
173}
174
175/// Returns information about a package, including dimensions, weight, time slot information for handover, invoice and item information, and status.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
176pub async fn get_scheduled_package(configuration: &configuration::Configuration, amazon_order_id: &str, marketplace_id: &str) -> Result<models::easy_ship_2022_03_23::Package, Error<GetScheduledPackageError>> {
177    // add a prefix to parameters to efficiently prevent name collisions
178    let p_amazon_order_id = amazon_order_id;
179    let p_marketplace_id = marketplace_id;
180
181    let uri_str = format!("{}/easyShip/2022-03-23/package", configuration.base_path);
182    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
183
184    req_builder = req_builder.query(&[("amazonOrderId", &p_amazon_order_id.to_string())]);
185    req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.to_string())]);
186    if let Some(ref user_agent) = configuration.user_agent {
187        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
188    }
189
190    let req = req_builder.build()?;
191    let resp = configuration.client.execute(req).await?;
192
193    let status = resp.status();
194    let content_type = resp
195        .headers()
196        .get("content-type")
197        .and_then(|v| v.to_str().ok())
198        .unwrap_or("application/octet-stream");
199    let content_type = super::ContentType::from(content_type);
200
201    if !status.is_client_error() && !status.is_server_error() {
202        let content = resp.text().await?;
203        match content_type {
204            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
205            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::easy_ship_2022_03_23::Package`"))),
206            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::easy_ship_2022_03_23::Package`")))),
207        }
208    } else {
209        let content = resp.text().await?;
210        let entity: Option<GetScheduledPackageError> = serde_json::from_str(&content).ok();
211        Err(Error::ResponseError(ResponseContent { status, content, entity }))
212    }
213}
214
215/// Returns time slots available for Easy Ship orders to be scheduled based on the package weight and dimensions that the seller specifies.  This operation is available for scheduled and unscheduled orders based on marketplace support. See **Get Time Slots** in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table).  This operation can return time slots that have either pickup or drop-off handover methods - see **Supported Handover Methods** in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
216pub async fn list_handover_slots(configuration: &configuration::Configuration, list_handover_slots_request: Option<models::easy_ship_2022_03_23::ListHandoverSlotsRequest>) -> Result<models::easy_ship_2022_03_23::ListHandoverSlotsResponse, Error<ListHandoverSlotsError>> {
217    // add a prefix to parameters to efficiently prevent name collisions
218    let p_list_handover_slots_request = list_handover_slots_request;
219
220    let uri_str = format!("{}/easyShip/2022-03-23/timeSlot", configuration.base_path);
221    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
222
223    if let Some(ref user_agent) = configuration.user_agent {
224        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
225    }
226    req_builder = req_builder.json(&p_list_handover_slots_request);
227
228    let req = req_builder.build()?;
229    let resp = configuration.client.execute(req).await?;
230
231    let status = resp.status();
232    let content_type = resp
233        .headers()
234        .get("content-type")
235        .and_then(|v| v.to_str().ok())
236        .unwrap_or("application/octet-stream");
237    let content_type = super::ContentType::from(content_type);
238
239    if !status.is_client_error() && !status.is_server_error() {
240        let content = resp.text().await?;
241        match content_type {
242            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
243            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::easy_ship_2022_03_23::ListHandoverSlotsResponse`"))),
244            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::easy_ship_2022_03_23::ListHandoverSlotsResponse`")))),
245        }
246    } else {
247        let content = resp.text().await?;
248        let entity: Option<ListHandoverSlotsError> = serde_json::from_str(&content).ok();
249        Err(Error::ResponseError(ResponseContent { status, content, entity }))
250    }
251}
252
253/// Updates the time slot for handing over the package indicated by the specified `scheduledPackageId`. You can get the new `slotId` value for the time slot by calling the `listHandoverSlots` operation before making another `patch` call.  See the **Update Package** column in the [Marketplace Support Table](doc:easyship-api-v2022-03-23-use-case-guide#marketplace-support-table) to see which marketplaces this operation is supported in.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
254pub async fn update_scheduled_packages(configuration: &configuration::Configuration, update_scheduled_packages_request: Option<models::easy_ship_2022_03_23::UpdateScheduledPackagesRequest>) -> Result<models::easy_ship_2022_03_23::Packages, Error<UpdateScheduledPackagesError>> {
255    // add a prefix to parameters to efficiently prevent name collisions
256    let p_update_scheduled_packages_request = update_scheduled_packages_request;
257
258    let uri_str = format!("{}/easyShip/2022-03-23/package", configuration.base_path);
259    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
260
261    if let Some(ref user_agent) = configuration.user_agent {
262        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
263    }
264    req_builder = req_builder.json(&p_update_scheduled_packages_request);
265
266    let req = req_builder.build()?;
267    let resp = configuration.client.execute(req).await?;
268
269    let status = resp.status();
270    let content_type = resp
271        .headers()
272        .get("content-type")
273        .and_then(|v| v.to_str().ok())
274        .unwrap_or("application/octet-stream");
275    let content_type = super::ContentType::from(content_type);
276
277    if !status.is_client_error() && !status.is_server_error() {
278        let content = resp.text().await?;
279        match content_type {
280            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
281            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::easy_ship_2022_03_23::Packages`"))),
282            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::easy_ship_2022_03_23::Packages`")))),
283        }
284    } else {
285        let content = resp.text().await?;
286        let entity: Option<UpdateScheduledPackagesError> = serde_json::from_str(&content).ok();
287        Err(Error::ResponseError(ResponseContent { status, content, entity }))
288    }
289}
290