amazon_spapi/apis/
vendor_shipments_v1.rs

1/*
2 * Selling Partner API for Retail Procurement Shipments
3 *
4 * The Selling Partner API for Retail Procurement Shipments provides programmatic access to retail shipping data for vendors.
5 *
6 * The version of the OpenAPI document: v1
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 [`get_shipment_details`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetShipmentDetailsError {
22    Status400(models::vendor_shipments::GetShipmentDetailsResponse),
23    Status401(models::vendor_shipments::GetShipmentDetailsResponse),
24    Status403(models::vendor_shipments::GetShipmentDetailsResponse),
25    Status404(models::vendor_shipments::GetShipmentDetailsResponse),
26    Status415(models::vendor_shipments::GetShipmentDetailsResponse),
27    Status429(models::vendor_shipments::GetShipmentDetailsResponse),
28    Status500(models::vendor_shipments::GetShipmentDetailsResponse),
29    Status503(models::vendor_shipments::GetShipmentDetailsResponse),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`get_shipment_labels`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetShipmentLabelsError {
37    Status400(models::vendor_shipments::GetShipmentLabels),
38    Status401(models::vendor_shipments::GetShipmentLabels),
39    Status403(models::vendor_shipments::GetShipmentLabels),
40    Status404(models::vendor_shipments::GetShipmentLabels),
41    Status415(models::vendor_shipments::GetShipmentLabels),
42    Status429(models::vendor_shipments::GetShipmentLabels),
43    Status500(models::vendor_shipments::GetShipmentLabels),
44    Status503(models::vendor_shipments::GetShipmentLabels),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`submit_shipment_confirmations`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum SubmitShipmentConfirmationsError {
52    Status400(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
53    Status403(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
54    Status404(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
55    Status413(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
56    Status415(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
57    Status429(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
58    Status500(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
59    Status503(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`submit_shipments`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum SubmitShipmentsError {
67    Status400(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
68    Status403(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
69    Status404(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
70    Status413(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
71    Status415(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
72    Status429(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
73    Status500(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
74    Status503(models::vendor_shipments::SubmitShipmentConfirmationsResponse),
75    UnknownValue(serde_json::Value),
76}
77
78
79/// Returns the Details about Shipment, Carrier Details,  status of the shipment, container details and other details related to shipment based on the filter parameters value that you specify.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
80pub async fn get_shipment_details(configuration: &configuration::Configuration, limit: Option<i64>, sort_order: Option<&str>, next_token: Option<&str>, created_after: Option<String>, created_before: Option<String>, shipment_confirmed_before: Option<String>, shipment_confirmed_after: Option<String>, package_label_created_before: Option<String>, package_label_created_after: Option<String>, shipped_before: Option<String>, shipped_after: Option<String>, estimated_delivery_before: Option<String>, estimated_delivery_after: Option<String>, shipment_delivery_before: Option<String>, shipment_delivery_after: Option<String>, requested_pick_up_before: Option<String>, requested_pick_up_after: Option<String>, scheduled_pick_up_before: Option<String>, scheduled_pick_up_after: Option<String>, current_shipment_status: Option<&str>, vendor_shipment_identifier: Option<&str>, buyer_reference_number: Option<&str>, buyer_warehouse_code: Option<&str>, seller_warehouse_code: Option<&str>) -> Result<models::vendor_shipments::GetShipmentDetailsResponse, Error<GetShipmentDetailsError>> {
81    // add a prefix to parameters to efficiently prevent name collisions
82    let p_limit = limit;
83    let p_sort_order = sort_order;
84    let p_next_token = next_token;
85    let p_created_after = created_after;
86    let p_created_before = created_before;
87    let p_shipment_confirmed_before = shipment_confirmed_before;
88    let p_shipment_confirmed_after = shipment_confirmed_after;
89    let p_package_label_created_before = package_label_created_before;
90    let p_package_label_created_after = package_label_created_after;
91    let p_shipped_before = shipped_before;
92    let p_shipped_after = shipped_after;
93    let p_estimated_delivery_before = estimated_delivery_before;
94    let p_estimated_delivery_after = estimated_delivery_after;
95    let p_shipment_delivery_before = shipment_delivery_before;
96    let p_shipment_delivery_after = shipment_delivery_after;
97    let p_requested_pick_up_before = requested_pick_up_before;
98    let p_requested_pick_up_after = requested_pick_up_after;
99    let p_scheduled_pick_up_before = scheduled_pick_up_before;
100    let p_scheduled_pick_up_after = scheduled_pick_up_after;
101    let p_current_shipment_status = current_shipment_status;
102    let p_vendor_shipment_identifier = vendor_shipment_identifier;
103    let p_buyer_reference_number = buyer_reference_number;
104    let p_buyer_warehouse_code = buyer_warehouse_code;
105    let p_seller_warehouse_code = seller_warehouse_code;
106
107    let uri_str = format!("{}/vendor/shipping/v1/shipments", configuration.base_path);
108    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
109
110    if let Some(ref param_value) = p_limit {
111        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
112    }
113    if let Some(ref param_value) = p_sort_order {
114        req_builder = req_builder.query(&[("sortOrder", &param_value.to_string())]);
115    }
116    if let Some(ref param_value) = p_next_token {
117        req_builder = req_builder.query(&[("nextToken", &param_value.to_string())]);
118    }
119    if let Some(ref param_value) = p_created_after {
120        req_builder = req_builder.query(&[("createdAfter", &param_value.to_string())]);
121    }
122    if let Some(ref param_value) = p_created_before {
123        req_builder = req_builder.query(&[("createdBefore", &param_value.to_string())]);
124    }
125    if let Some(ref param_value) = p_shipment_confirmed_before {
126        req_builder = req_builder.query(&[("shipmentConfirmedBefore", &param_value.to_string())]);
127    }
128    if let Some(ref param_value) = p_shipment_confirmed_after {
129        req_builder = req_builder.query(&[("shipmentConfirmedAfter", &param_value.to_string())]);
130    }
131    if let Some(ref param_value) = p_package_label_created_before {
132        req_builder = req_builder.query(&[("packageLabelCreatedBefore", &param_value.to_string())]);
133    }
134    if let Some(ref param_value) = p_package_label_created_after {
135        req_builder = req_builder.query(&[("packageLabelCreatedAfter", &param_value.to_string())]);
136    }
137    if let Some(ref param_value) = p_shipped_before {
138        req_builder = req_builder.query(&[("shippedBefore", &param_value.to_string())]);
139    }
140    if let Some(ref param_value) = p_shipped_after {
141        req_builder = req_builder.query(&[("shippedAfter", &param_value.to_string())]);
142    }
143    if let Some(ref param_value) = p_estimated_delivery_before {
144        req_builder = req_builder.query(&[("estimatedDeliveryBefore", &param_value.to_string())]);
145    }
146    if let Some(ref param_value) = p_estimated_delivery_after {
147        req_builder = req_builder.query(&[("estimatedDeliveryAfter", &param_value.to_string())]);
148    }
149    if let Some(ref param_value) = p_shipment_delivery_before {
150        req_builder = req_builder.query(&[("shipmentDeliveryBefore", &param_value.to_string())]);
151    }
152    if let Some(ref param_value) = p_shipment_delivery_after {
153        req_builder = req_builder.query(&[("shipmentDeliveryAfter", &param_value.to_string())]);
154    }
155    if let Some(ref param_value) = p_requested_pick_up_before {
156        req_builder = req_builder.query(&[("requestedPickUpBefore", &param_value.to_string())]);
157    }
158    if let Some(ref param_value) = p_requested_pick_up_after {
159        req_builder = req_builder.query(&[("requestedPickUpAfter", &param_value.to_string())]);
160    }
161    if let Some(ref param_value) = p_scheduled_pick_up_before {
162        req_builder = req_builder.query(&[("scheduledPickUpBefore", &param_value.to_string())]);
163    }
164    if let Some(ref param_value) = p_scheduled_pick_up_after {
165        req_builder = req_builder.query(&[("scheduledPickUpAfter", &param_value.to_string())]);
166    }
167    if let Some(ref param_value) = p_current_shipment_status {
168        req_builder = req_builder.query(&[("currentShipmentStatus", &param_value.to_string())]);
169    }
170    if let Some(ref param_value) = p_vendor_shipment_identifier {
171        req_builder = req_builder.query(&[("vendorShipmentIdentifier", &param_value.to_string())]);
172    }
173    if let Some(ref param_value) = p_buyer_reference_number {
174        req_builder = req_builder.query(&[("buyerReferenceNumber", &param_value.to_string())]);
175    }
176    if let Some(ref param_value) = p_buyer_warehouse_code {
177        req_builder = req_builder.query(&[("buyerWarehouseCode", &param_value.to_string())]);
178    }
179    if let Some(ref param_value) = p_seller_warehouse_code {
180        req_builder = req_builder.query(&[("sellerWarehouseCode", &param_value.to_string())]);
181    }
182    if let Some(ref user_agent) = configuration.user_agent {
183        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
184    }
185
186    let req = req_builder.build()?;
187    let resp = configuration.client.execute(req).await?;
188
189    let status = resp.status();
190    let content_type = resp
191        .headers()
192        .get("content-type")
193        .and_then(|v| v.to_str().ok())
194        .unwrap_or("application/octet-stream");
195    let content_type = super::ContentType::from(content_type);
196
197    if !status.is_client_error() && !status.is_server_error() {
198        let content = resp.text().await?;
199        match content_type {
200            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
201            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::vendor_shipments::GetShipmentDetailsResponse`"))),
202            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::vendor_shipments::GetShipmentDetailsResponse`")))),
203        }
204    } else {
205        let content = resp.text().await?;
206        let entity: Option<GetShipmentDetailsError> = serde_json::from_str(&content).ok();
207        Err(Error::ResponseError(ResponseContent { status, content, entity }))
208    }
209}
210
211/// Returns small parcel shipment labels based on the filters that you specify.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  The `x-amzn-RateLimit-Limit` response header contains the usage plan rate limits for the operation, when available. The preceding table contains the default rate and burst values for this operation. Selling partners whose business demands require higher throughput might have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
212pub async fn get_shipment_labels(configuration: &configuration::Configuration, limit: Option<i64>, sort_order: Option<&str>, next_token: Option<&str>, label_created_after: Option<String>, label_created_before: Option<String>, buyer_reference_number: Option<&str>, vendor_shipment_identifier: Option<&str>, seller_warehouse_code: Option<&str>) -> Result<models::vendor_shipments::GetShipmentLabels, Error<GetShipmentLabelsError>> {
213    // add a prefix to parameters to efficiently prevent name collisions
214    let p_limit = limit;
215    let p_sort_order = sort_order;
216    let p_next_token = next_token;
217    let p_label_created_after = label_created_after;
218    let p_label_created_before = label_created_before;
219    let p_buyer_reference_number = buyer_reference_number;
220    let p_vendor_shipment_identifier = vendor_shipment_identifier;
221    let p_seller_warehouse_code = seller_warehouse_code;
222
223    let uri_str = format!("{}/vendor/shipping/v1/transportLabels", configuration.base_path);
224    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
225
226    if let Some(ref param_value) = p_limit {
227        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
228    }
229    if let Some(ref param_value) = p_sort_order {
230        req_builder = req_builder.query(&[("sortOrder", &param_value.to_string())]);
231    }
232    if let Some(ref param_value) = p_next_token {
233        req_builder = req_builder.query(&[("nextToken", &param_value.to_string())]);
234    }
235    if let Some(ref param_value) = p_label_created_after {
236        req_builder = req_builder.query(&[("labelCreatedAfter", &param_value.to_string())]);
237    }
238    if let Some(ref param_value) = p_label_created_before {
239        req_builder = req_builder.query(&[("labelCreatedBefore", &param_value.to_string())]);
240    }
241    if let Some(ref param_value) = p_buyer_reference_number {
242        req_builder = req_builder.query(&[("buyerReferenceNumber", &param_value.to_string())]);
243    }
244    if let Some(ref param_value) = p_vendor_shipment_identifier {
245        req_builder = req_builder.query(&[("vendorShipmentIdentifier", &param_value.to_string())]);
246    }
247    if let Some(ref param_value) = p_seller_warehouse_code {
248        req_builder = req_builder.query(&[("sellerWarehouseCode", &param_value.to_string())]);
249    }
250    if let Some(ref user_agent) = configuration.user_agent {
251        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
252    }
253
254    let req = req_builder.build()?;
255    let resp = configuration.client.execute(req).await?;
256
257    let status = resp.status();
258    let content_type = resp
259        .headers()
260        .get("content-type")
261        .and_then(|v| v.to_str().ok())
262        .unwrap_or("application/octet-stream");
263    let content_type = super::ContentType::from(content_type);
264
265    if !status.is_client_error() && !status.is_server_error() {
266        let content = resp.text().await?;
267        match content_type {
268            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
269            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::vendor_shipments::GetShipmentLabels`"))),
270            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::vendor_shipments::GetShipmentLabels`")))),
271        }
272    } else {
273        let content = resp.text().await?;
274        let entity: Option<GetShipmentLabelsError> = serde_json::from_str(&content).ok();
275        Err(Error::ResponseError(ResponseContent { status, content, entity }))
276    }
277}
278
279/// Submits one or more shipment confirmations for vendor orders.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
280pub async fn submit_shipment_confirmations(configuration: &configuration::Configuration, body: models::vendor_shipments::SubmitShipmentConfirmationsRequest) -> Result<models::vendor_shipments::SubmitShipmentConfirmationsResponse, Error<SubmitShipmentConfirmationsError>> {
281    // add a prefix to parameters to efficiently prevent name collisions
282    let p_body = body;
283
284    let uri_str = format!("{}/vendor/shipping/v1/shipmentConfirmations", configuration.base_path);
285    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
286
287    if let Some(ref user_agent) = configuration.user_agent {
288        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
289    }
290    req_builder = req_builder.json(&p_body);
291
292    let req = req_builder.build()?;
293    let resp = configuration.client.execute(req).await?;
294
295    let status = resp.status();
296    let content_type = resp
297        .headers()
298        .get("content-type")
299        .and_then(|v| v.to_str().ok())
300        .unwrap_or("application/octet-stream");
301    let content_type = super::ContentType::from(content_type);
302
303    if !status.is_client_error() && !status.is_server_error() {
304        let content = resp.text().await?;
305        match content_type {
306            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
307            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::vendor_shipments::SubmitShipmentConfirmationsResponse`"))),
308            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::vendor_shipments::SubmitShipmentConfirmationsResponse`")))),
309        }
310    } else {
311        let content = resp.text().await?;
312        let entity: Option<SubmitShipmentConfirmationsError> = serde_json::from_str(&content).ok();
313        Err(Error::ResponseError(ResponseContent { status, content, entity }))
314    }
315}
316
317/// Submits one or more shipment request for vendor Orders.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
318pub async fn submit_shipments(configuration: &configuration::Configuration, body: models::vendor_shipments::SubmitShipments) -> Result<models::vendor_shipments::SubmitShipmentConfirmationsResponse, Error<SubmitShipmentsError>> {
319    // add a prefix to parameters to efficiently prevent name collisions
320    let p_body = body;
321
322    let uri_str = format!("{}/vendor/shipping/v1/shipments", configuration.base_path);
323    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
324
325    if let Some(ref user_agent) = configuration.user_agent {
326        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
327    }
328    req_builder = req_builder.json(&p_body);
329
330    let req = req_builder.build()?;
331    let resp = configuration.client.execute(req).await?;
332
333    let status = resp.status();
334    let content_type = resp
335        .headers()
336        .get("content-type")
337        .and_then(|v| v.to_str().ok())
338        .unwrap_or("application/octet-stream");
339    let content_type = super::ContentType::from(content_type);
340
341    if !status.is_client_error() && !status.is_server_error() {
342        let content = resp.text().await?;
343        match content_type {
344            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
345            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::vendor_shipments::SubmitShipmentConfirmationsResponse`"))),
346            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::vendor_shipments::SubmitShipmentConfirmationsResponse`")))),
347        }
348    } else {
349        let content = resp.text().await?;
350        let entity: Option<SubmitShipmentsError> = serde_json::from_str(&content).ok();
351        Err(Error::ResponseError(ResponseContent { status, content, entity }))
352    }
353}
354