/*
* Selling Partner API for Listings Items
*
* The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API. For more information, see the [Listings Items API Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-use-case-guide).
*
* The version of the OpenAPI document: 2021-08-01
*
* Generated by: https://openapi-generator.tech
*/
use super::{configuration, ContentType, Error};
use crate::{apis::ResponseContent, models};
use reqwest;
use serde::{de::Error as _, Deserialize, Serialize};
/// struct for typed errors of method [`delete_listings_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteListingsItemError {
Status400(models::listings_items_2021_08_01::ErrorList),
Status403(models::listings_items_2021_08_01::ErrorList),
Status413(models::listings_items_2021_08_01::ErrorList),
Status415(models::listings_items_2021_08_01::ErrorList),
Status429(models::listings_items_2021_08_01::ErrorList),
Status500(models::listings_items_2021_08_01::ErrorList),
Status503(models::listings_items_2021_08_01::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`get_listings_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetListingsItemError {
Status400(models::listings_items_2021_08_01::ErrorList),
Status403(models::listings_items_2021_08_01::ErrorList),
Status404(models::listings_items_2021_08_01::ErrorList),
Status413(models::listings_items_2021_08_01::ErrorList),
Status415(models::listings_items_2021_08_01::ErrorList),
Status429(models::listings_items_2021_08_01::ErrorList),
Status500(models::listings_items_2021_08_01::ErrorList),
Status503(models::listings_items_2021_08_01::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`patch_listings_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PatchListingsItemError {
Status400(models::listings_items_2021_08_01::ErrorList),
Status403(models::listings_items_2021_08_01::ErrorList),
Status413(models::listings_items_2021_08_01::ErrorList),
Status415(models::listings_items_2021_08_01::ErrorList),
Status429(models::listings_items_2021_08_01::ErrorList),
Status500(models::listings_items_2021_08_01::ErrorList),
Status503(models::listings_items_2021_08_01::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`put_listings_item`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PutListingsItemError {
Status400(models::listings_items_2021_08_01::ErrorList),
Status403(models::listings_items_2021_08_01::ErrorList),
Status413(models::listings_items_2021_08_01::ErrorList),
Status415(models::listings_items_2021_08_01::ErrorList),
Status429(models::listings_items_2021_08_01::ErrorList),
Status500(models::listings_items_2021_08_01::ErrorList),
Status503(models::listings_items_2021_08_01::ErrorList),
UnknownValue(serde_json::Value),
}
/// struct for typed errors of method [`search_listings_items`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SearchListingsItemsError {
Status400(models::listings_items_2021_08_01::ErrorList),
Status403(models::listings_items_2021_08_01::ErrorList),
Status404(models::listings_items_2021_08_01::ErrorList),
Status413(models::listings_items_2021_08_01::ErrorList),
Status415(models::listings_items_2021_08_01::ErrorList),
Status429(models::listings_items_2021_08_01::ErrorList),
Status500(models::listings_items_2021_08_01::ErrorList),
Status503(models::listings_items_2021_08_01::ErrorList),
UnknownValue(serde_json::Value),
}
/// Delete a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | 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 can receive 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) in the Selling Partner API documentation.
pub async fn delete_listings_item(
configuration: &configuration::Configuration,
seller_id: &str,
sku: &str,
marketplace_ids: Vec<String>,
issue_locale: Option<&str>,
) -> Result<
models::listings_items_2021_08_01::ListingsItemSubmissionResponse,
Error<DeleteListingsItemError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_seller_id = seller_id;
let p_sku = sku;
let p_marketplace_ids = marketplace_ids;
let p_issue_locale = issue_locale;
let uri_str = format!(
"{}/listings/2021-08-01/items/{sellerId}/{sku}",
configuration.base_path,
sellerId = crate::apis::urlencode(p_seller_id),
sku = crate::apis::urlencode(p_sku)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::DELETE, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_marketplace_ids
.into_iter()
.map(|p| ("marketplaceIds".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"marketplaceIds",
&p_marketplace_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref param_value) = p_issue_locale {
req_builder = req_builder.query(&[("issueLocale", ¶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::listings_items_2021_08_01::ListingsItemSubmissionResponse`"))),
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::listings_items_2021_08_01::ListingsItemSubmissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteListingsItemError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Returns details about a listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 | 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 can receive 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) in the Selling Partner API documentation.
pub async fn get_listings_item(
configuration: &configuration::Configuration,
seller_id: &str,
sku: &str,
marketplace_ids: Vec<String>,
issue_locale: Option<&str>,
included_data: Option<Vec<String>>,
) -> Result<models::listings_items_2021_08_01::Item, Error<GetListingsItemError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_seller_id = seller_id;
let p_sku = sku;
let p_marketplace_ids = marketplace_ids;
let p_issue_locale = issue_locale;
let p_included_data = included_data;
let uri_str = format!(
"{}/listings/2021-08-01/items/{sellerId}/{sku}",
configuration.base_path,
sellerId = crate::apis::urlencode(p_seller_id),
sku = crate::apis::urlencode(p_sku)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_marketplace_ids
.into_iter()
.map(|p| ("marketplaceIds".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"marketplaceIds",
&p_marketplace_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref param_value) = p_issue_locale {
req_builder = req_builder.query(&[("issueLocale", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_included_data {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("includedData".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"includedData",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.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::listings_items_2021_08_01::Item`"))),
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::listings_items_2021_08_01::Item`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetListingsItemError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Partially update (patch) a listings item for a selling partner. Only top-level listings item attributes can be patched. Patching nested attributes is not supported. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | 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 can receive 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) in the Selling Partner API documentation.
pub async fn patch_listings_item(
configuration: &configuration::Configuration,
seller_id: &str,
sku: &str,
marketplace_ids: Vec<String>,
body: models::listings_items_2021_08_01::ListingsItemPatchRequest,
included_data: Option<Vec<String>>,
mode: Option<&str>,
issue_locale: Option<&str>,
) -> Result<
models::listings_items_2021_08_01::ListingsItemSubmissionResponse,
Error<PatchListingsItemError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_seller_id = seller_id;
let p_sku = sku;
let p_marketplace_ids = marketplace_ids;
let p_body = body;
let p_included_data = included_data;
let p_mode = mode;
let p_issue_locale = issue_locale;
let uri_str = format!(
"{}/listings/2021-08-01/items/{sellerId}/{sku}",
configuration.base_path,
sellerId = crate::apis::urlencode(p_seller_id),
sku = crate::apis::urlencode(p_sku)
);
let mut req_builder = configuration
.client
.request(reqwest::Method::PATCH, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_marketplace_ids
.into_iter()
.map(|p| ("marketplaceIds".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"marketplaceIds",
&p_marketplace_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref param_value) = p_included_data {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("includedData".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"includedData",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_mode {
req_builder = req_builder.query(&[("mode", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_issue_locale {
req_builder = req_builder.query(&[("issueLocale", ¶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());
}
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::listings_items_2021_08_01::ListingsItemSubmissionResponse`"))),
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::listings_items_2021_08_01::ListingsItemSubmissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchListingsItemError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Creates a new or fully-updates an existing listings item for a selling partner. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 10 | 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 can receive 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) in the Selling Partner API documentation.
pub async fn put_listings_item(
configuration: &configuration::Configuration,
seller_id: &str,
sku: &str,
marketplace_ids: Vec<String>,
body: models::listings_items_2021_08_01::ListingsItemPutRequest,
included_data: Option<Vec<String>>,
mode: Option<&str>,
issue_locale: Option<&str>,
) -> Result<
models::listings_items_2021_08_01::ListingsItemSubmissionResponse,
Error<PutListingsItemError>,
> {
// add a prefix to parameters to efficiently prevent name collisions
let p_seller_id = seller_id;
let p_sku = sku;
let p_marketplace_ids = marketplace_ids;
let p_body = body;
let p_included_data = included_data;
let p_mode = mode;
let p_issue_locale = issue_locale;
let uri_str = format!(
"{}/listings/2021-08-01/items/{sellerId}/{sku}",
configuration.base_path,
sellerId = crate::apis::urlencode(p_seller_id),
sku = crate::apis::urlencode(p_sku)
);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_marketplace_ids
.into_iter()
.map(|p| ("marketplaceIds".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"marketplaceIds",
&p_marketplace_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref param_value) = p_included_data {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("includedData".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"includedData",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_mode {
req_builder = req_builder.query(&[("mode", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_issue_locale {
req_builder = req_builder.query(&[("issueLocale", ¶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());
}
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::listings_items_2021_08_01::ListingsItemSubmissionResponse`"))),
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::listings_items_2021_08_01::ListingsItemSubmissionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PutListingsItemError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}
/// Search for and return a list of selling partner listings items and their respective details. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 5 | 5 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that are applied to the requested 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).
pub async fn search_listings_items(
configuration: &configuration::Configuration,
seller_id: &str,
marketplace_ids: Vec<String>,
issue_locale: Option<&str>,
included_data: Option<Vec<String>>,
identifiers: Option<Vec<String>>,
identifiers_type: Option<&str>,
variation_parent_sku: Option<&str>,
package_hierarchy_sku: Option<&str>,
created_after: Option<String>,
created_before: Option<String>,
last_updated_after: Option<String>,
last_updated_before: Option<String>,
with_issue_severity: Option<Vec<String>>,
with_status: Option<Vec<String>>,
without_status: Option<Vec<String>>,
sort_by: Option<&str>,
sort_order: Option<&str>,
page_size: Option<i32>,
page_token: Option<&str>,
) -> Result<models::listings_items_2021_08_01::ItemSearchResults, Error<SearchListingsItemsError>> {
// add a prefix to parameters to efficiently prevent name collisions
let p_seller_id = seller_id;
let p_marketplace_ids = marketplace_ids;
let p_issue_locale = issue_locale;
let p_included_data = included_data;
let p_identifiers = identifiers;
let p_identifiers_type = identifiers_type;
let p_variation_parent_sku = variation_parent_sku;
let p_package_hierarchy_sku = package_hierarchy_sku;
let p_created_after = created_after;
let p_created_before = created_before;
let p_last_updated_after = last_updated_after;
let p_last_updated_before = last_updated_before;
let p_with_issue_severity = with_issue_severity;
let p_with_status = with_status;
let p_without_status = without_status;
let p_sort_by = sort_by;
let p_sort_order = sort_order;
let p_page_size = page_size;
let p_page_token = page_token;
let uri_str = format!(
"{}/listings/2021-08-01/items/{sellerId}",
configuration.base_path,
sellerId = crate::apis::urlencode(p_seller_id)
);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = match "csv" {
"multi" => req_builder.query(
&p_marketplace_ids
.into_iter()
.map(|p| ("marketplaceIds".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"marketplaceIds",
&p_marketplace_ids
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
if let Some(ref param_value) = p_issue_locale {
req_builder = req_builder.query(&[("issueLocale", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_included_data {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("includedData".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"includedData",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_identifiers {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("identifiers".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"identifiers",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_identifiers_type {
req_builder = req_builder.query(&[("identifiersType", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_variation_parent_sku {
req_builder = req_builder.query(&[("variationParentSku", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_package_hierarchy_sku {
req_builder = req_builder.query(&[("packageHierarchySku", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_created_after {
req_builder = req_builder.query(&[("createdAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_created_before {
req_builder = req_builder.query(&[("createdBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_last_updated_after {
req_builder = req_builder.query(&[("lastUpdatedAfter", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_last_updated_before {
req_builder = req_builder.query(&[("lastUpdatedBefore", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_with_issue_severity {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("withIssueSeverity".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"withIssueSeverity",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_with_status {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("withStatus".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"withStatus",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref param_value) = p_without_status {
req_builder = match "csv" {
"multi" => req_builder.query(
¶m_value
.into_iter()
.map(|p| ("withoutStatus".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => req_builder.query(&[(
"withoutStatus",
¶m_value
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
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_page_size {
req_builder = req_builder.query(&[("pageSize", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_page_token {
req_builder = req_builder.query(&[("pageToken", ¶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::listings_items_2021_08_01::ItemSearchResults`"))),
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::listings_items_2021_08_01::ItemSearchResults`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SearchListingsItemsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent {
status,
content,
entity,
}))
}
}