/*
* The Selling Partner API for Amazon Warehousing and Distribution
*
* The Selling Partner API for Amazon Warehousing and Distribution (AWD) provides programmatic access to information about AWD shipments and inventory.
*
* The version of the OpenAPI document: 2024-05-09
*
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
/// struct for typed errors of method [`cancel_inbound`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CancelInboundError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status409(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`check_inbound_eligibility`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CheckInboundEligibilityError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`confirm_inbound`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ConfirmInboundError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status409(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`create_inbound`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateInboundError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_inbound`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboundError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_inbound_shipment`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboundShipmentError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_inbound_shipment_labels`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetInboundShipmentLabelsError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_inbound_shipments`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInboundShipmentsError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`list_inventory`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ListInventoryError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_inbound`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateInboundError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status409(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`update_inbound_shipment_transport_details`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateInboundShipmentTransportDetailsError {
Status400(models::awd_2024_05_09::ErrorList),
Status403(models::awd_2024_05_09::ErrorList),
Status404(models::awd_2024_05_09::ErrorList),
Status413(models::awd_2024_05_09::ErrorList),
Status415(models::awd_2024_05_09::ErrorList),
Status429(models::awd_2024_05_09::ErrorList),
Status500(models::awd_2024_05_09::ErrorList),
Status503(models::awd_2024_05_09::ErrorList),
UnknownValue(serde_json::Value),
}
/// Cancels an AWD Inbound order and its associated shipment. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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).
pub async fn cancel_inbound(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<CancelInboundError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_order_id = order_id;
let uri_str = format!("{}/awd/2024-05-09/inboundOrders/{orderId}/cancellation", configuration.base_path, orderId=crate::apis::urlencode(p_order_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<CancelInboundError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Determines if the packages you specify are eligible for an AWD inbound order and contains error details for ineligible packages. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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).
pub async fn check_inbound_eligibility(configuration: &configuration::Configuration, body: models::awd_2024_05_09::InboundPackages) -> Result<models::awd_2024_05_09::InboundEligibility, Error<CheckInboundEligibilityError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body = body;
let uri_str = format!("{}/awd/2024-05-09/inboundEligibility", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::InboundEligibility`"))),
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::awd_2024_05_09::InboundEligibility`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CheckInboundEligibilityError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Confirms an AWD inbound order in `DRAFT` status. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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, refer to [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).
pub async fn confirm_inbound(configuration: &configuration::Configuration, order_id: &str) -> Result<(), Error<ConfirmInboundError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_order_id = order_id;
let uri_str = format!("{}/awd/2024-05-09/inboundOrders/{orderId}/confirmation", configuration.base_path, orderId=crate::apis::urlencode(p_order_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<ConfirmInboundError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Creates a draft AWD inbound order with a list of packages for inbound shipment. The operation creates one shipment per order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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).
pub async fn create_inbound(configuration: &configuration::Configuration, body: models::awd_2024_05_09::InboundOrderCreationData) -> Result<models::awd_2024_05_09::InboundOrderReference, Error<CreateInboundError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_body = body;
let uri_str = format!("{}/awd/2024-05-09/inboundOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::InboundOrderReference`"))),
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::awd_2024_05_09::InboundOrderReference`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateInboundError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Retrieves an AWD inbound order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 2 | 2 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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).
pub async fn get_inbound(configuration: &configuration::Configuration, order_id: &str) -> Result<models::awd_2024_05_09::InboundOrder, Error<GetInboundError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_order_id = order_id;
let uri_str = format!("{}/awd/2024-05-09/inboundOrders/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(p_order_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::InboundOrder`"))),
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::awd_2024_05_09::InboundOrder`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetInboundError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Retrieves an AWD inbound shipment. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 2 | 2 | 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, refer to [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)
pub async fn get_inbound_shipment(configuration: &configuration::Configuration, shipment_id: &str, sku_quantities: Option<&str>) -> Result<models::awd_2024_05_09::InboundShipment, Error<GetInboundShipmentError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_shipment_id = shipment_id;
let p_sku_quantities = sku_quantities;
let uri_str = format!("{}/awd/2024-05-09/inboundShipments/{shipmentId}", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_sku_quantities {
req_builder = req_builder.query(&[("skuQuantities", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::InboundShipment`"))),
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::awd_2024_05_09::InboundShipment`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetInboundShipmentError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Retrieves the box labels for a shipment ID that you specify. This is an asynchronous operation. If the label status is `GENERATED`, then the label URL is available. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 2 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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).
pub async fn get_inbound_shipment_labels(configuration: &configuration::Configuration, shipment_id: &str, page_type: Option<&str>, format_type: Option<&str>) -> Result<models::awd_2024_05_09::ShipmentLabels, Error<GetInboundShipmentLabelsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_shipment_id = shipment_id;
let p_page_type = page_type;
let p_format_type = format_type;
let uri_str = format!("{}/awd/2024-05-09/inboundShipments/{shipmentId}/labels", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_page_type {
req_builder = req_builder.query(&[("pageType", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_format_type {
req_builder = req_builder.query(&[("formatType", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::ShipmentLabels`"))),
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::awd_2024_05_09::ShipmentLabels`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetInboundShipmentLabelsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Retrieves a summary of all the inbound AWD shipments associated with a merchant, with the ability to apply optional filters. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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, refer to [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).
pub async fn list_inbound_shipments(configuration: &configuration::Configuration, sort_by: Option<&str>, sort_order: Option<&str>, shipment_status: Option<&str>, updated_after: Option<String>, updated_before: Option<String>, max_results: Option<i32>, next_token: Option<&str>) -> Result<models::awd_2024_05_09::ShipmentListing, Error<ListInboundShipmentsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_sort_by = sort_by;
let p_sort_order = sort_order;
let p_shipment_status = shipment_status;
let p_updated_after = updated_after;
let p_updated_before = updated_before;
let p_max_results = max_results;
let p_next_token = next_token;
let uri_str = format!("{}/awd/2024-05-09/inboundShipments", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_sort_by {
req_builder = req_builder.query(&[("sortBy", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_sort_order {
req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_shipment_status {
req_builder = req_builder.query(&[("shipmentStatus", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_updated_after {
req_builder = req_builder.query(&[("updatedAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_updated_before {
req_builder = req_builder.query(&[("updatedBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_max_results {
req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_next_token {
req_builder = req_builder.query(&[("nextToken", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::ShipmentListing`"))),
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::awd_2024_05_09::ShipmentListing`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListInboundShipmentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Lists AWD inventory associated with a merchant with the ability to apply optional filters. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 2 | 2 | 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, refer to [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).
pub async fn list_inventory(configuration: &configuration::Configuration, sku: Option<&str>, sort_order: Option<&str>, details: Option<&str>, next_token: Option<&str>, max_results: Option<i32>) -> Result<models::awd_2024_05_09::InventoryListing, Error<ListInventoryError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_sku = sku;
let p_sort_order = sort_order;
let p_details = details;
let p_next_token = next_token;
let p_max_results = max_results;
let uri_str = format!("{}/awd/2024-05-09/inventory", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_sku {
req_builder = req_builder.query(&[("sku", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_sort_order {
req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_details {
req_builder = req_builder.query(&[("details", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_next_token {
req_builder = req_builder.query(&[("nextToken", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_max_results {
req_builder = req_builder.query(&[("maxResults", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::awd_2024_05_09::InventoryListing`"))),
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::awd_2024_05_09::InventoryListing`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<ListInventoryError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Updates an AWD inbound order that is in `DRAFT` status and not yet confirmed. Use this operation to update the `packagesToInbound`, `originAddress` and `preferences` attributes. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [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).
pub async fn update_inbound(configuration: &configuration::Configuration, order_id: &str, body: models::awd_2024_05_09::InboundOrder) -> Result<(), Error<UpdateInboundError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_order_id = order_id;
let p_body = body;
let uri_str = format!("{}/awd/2024-05-09/inboundOrders/{orderId}", configuration.base_path, orderId=crate::apis::urlencode(p_order_id));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<UpdateInboundError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
/// Updates transport details for an AWD shipment. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 | 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, refer to [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).
pub async fn update_inbound_shipment_transport_details(configuration: &configuration::Configuration, shipment_id: &str, body: models::awd_2024_05_09::TransportationDetails) -> Result<(), Error<UpdateInboundShipmentTransportDetailsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_shipment_id = shipment_id;
let p_body = body;
let uri_str = format!("{}/awd/2024-05-09/inboundShipments/{shipmentId}/transport", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
req_builder = req_builder.json(&p_body);
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<UpdateInboundShipmentTransportDetailsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}