use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBrowseNodeReturnTopicsError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBrowseNodeReturnTrendsError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBrowseNodeReviewTopicsError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBrowseNodeReviewTrendsError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetItemBrowseNodeError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetItemReviewTopicsError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetItemReviewTrendsError {
Status400(models::customer_feedback_2024_06_01::ErrorList),
Status403(models::customer_feedback_2024_06_01::ErrorList),
Status404(models::customer_feedback_2024_06_01::ErrorList),
Status413(models::customer_feedback_2024_06_01::ErrorList),
Status415(models::customer_feedback_2024_06_01::ErrorList),
Status429(models::customer_feedback_2024_06_01::ErrorList),
Status500(models::customer_feedback_2024_06_01::ErrorList),
Status503(models::customer_feedback_2024_06_01::ErrorList),
UnknownValue(serde_json::Value),
}
pub async fn get_browse_node_return_topics(configuration: &configuration::Configuration, browse_node_id: &str, marketplace_id: &str) -> Result<models::customer_feedback_2024_06_01::BrowseNodeReturnTopicsResponse, Error<GetBrowseNodeReturnTopicsError>> {
let p_browse_node_id = browse_node_id;
let p_marketplace_id = marketplace_id;
let uri_str = format!("{}/customerFeedback/2024-06-01/browseNodes/{browseNodeId}/returns/topics", configuration.base_path, browseNodeId=crate::apis::urlencode(p_browse_node_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.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::customer_feedback_2024_06_01::BrowseNodeReturnTopicsResponse`"))),
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::customer_feedback_2024_06_01::BrowseNodeReturnTopicsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBrowseNodeReturnTopicsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_browse_node_return_trends(configuration: &configuration::Configuration, browse_node_id: &str, marketplace_id: &str) -> Result<models::customer_feedback_2024_06_01::BrowseNodeReturnTrendsResponse, Error<GetBrowseNodeReturnTrendsError>> {
let p_browse_node_id = browse_node_id;
let p_marketplace_id = marketplace_id;
let uri_str = format!("{}/customerFeedback/2024-06-01/browseNodes/{browseNodeId}/returns/trends", configuration.base_path, browseNodeId=crate::apis::urlencode(p_browse_node_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.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::customer_feedback_2024_06_01::BrowseNodeReturnTrendsResponse`"))),
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::customer_feedback_2024_06_01::BrowseNodeReturnTrendsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBrowseNodeReturnTrendsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_browse_node_review_topics(configuration: &configuration::Configuration, browse_node_id: &str, marketplace_id: &str, sort_by: &str) -> Result<models::customer_feedback_2024_06_01::BrowseNodeReviewTopicsResponse, Error<GetBrowseNodeReviewTopicsError>> {
let p_browse_node_id = browse_node_id;
let p_marketplace_id = marketplace_id;
let p_sort_by = sort_by;
let uri_str = format!("{}/customerFeedback/2024-06-01/browseNodes/{browseNodeId}/reviews/topics", configuration.base_path, browseNodeId=crate::apis::urlencode(p_browse_node_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.to_string())]);
req_builder = req_builder.query(&[("sortBy", &p_sort_by.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::customer_feedback_2024_06_01::BrowseNodeReviewTopicsResponse`"))),
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::customer_feedback_2024_06_01::BrowseNodeReviewTopicsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBrowseNodeReviewTopicsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_browse_node_review_trends(configuration: &configuration::Configuration, browse_node_id: &str, marketplace_id: &str) -> Result<models::customer_feedback_2024_06_01::BrowseNodeReviewTrendsResponse, Error<GetBrowseNodeReviewTrendsError>> {
let p_browse_node_id = browse_node_id;
let p_marketplace_id = marketplace_id;
let uri_str = format!("{}/customerFeedback/2024-06-01/browseNodes/{browseNodeId}/reviews/trends", configuration.base_path, browseNodeId=crate::apis::urlencode(p_browse_node_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.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::customer_feedback_2024_06_01::BrowseNodeReviewTrendsResponse`"))),
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::customer_feedback_2024_06_01::BrowseNodeReviewTrendsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBrowseNodeReviewTrendsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_item_browse_node(configuration: &configuration::Configuration, asin: &str, marketplace_id: &str) -> Result<models::customer_feedback_2024_06_01::BrowseNodeResponse, Error<GetItemBrowseNodeError>> {
let p_asin = asin;
let p_marketplace_id = marketplace_id;
let uri_str = format!("{}/customerFeedback/2024-06-01/items/{asin}/browseNode", configuration.base_path, asin=crate::apis::urlencode(p_asin));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.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::customer_feedback_2024_06_01::BrowseNodeResponse`"))),
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::customer_feedback_2024_06_01::BrowseNodeResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetItemBrowseNodeError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_item_review_topics(configuration: &configuration::Configuration, asin: &str, marketplace_id: &str, sort_by: &str) -> Result<models::customer_feedback_2024_06_01::ItemReviewTopicsResponse, Error<GetItemReviewTopicsError>> {
let p_asin = asin;
let p_marketplace_id = marketplace_id;
let p_sort_by = sort_by;
let uri_str = format!("{}/customerFeedback/2024-06-01/items/{asin}/reviews/topics", configuration.base_path, asin=crate::apis::urlencode(p_asin));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.to_string())]);
req_builder = req_builder.query(&[("sortBy", &p_sort_by.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::customer_feedback_2024_06_01::ItemReviewTopicsResponse`"))),
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::customer_feedback_2024_06_01::ItemReviewTopicsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetItemReviewTopicsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_item_review_trends(configuration: &configuration::Configuration, asin: &str, marketplace_id: &str) -> Result<models::customer_feedback_2024_06_01::ItemReviewTrendsResponse, Error<GetItemReviewTrendsError>> {
let p_asin = asin;
let p_marketplace_id = marketplace_id;
let uri_str = format!("{}/customerFeedback/2024-06-01/items/{asin}/reviews/trends", configuration.base_path, asin=crate::apis::urlencode(p_asin));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
req_builder = req_builder.query(&[("marketplaceId", &p_marketplace_id.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::customer_feedback_2024_06_01::ItemReviewTrendsResponse`"))),
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::customer_feedback_2024_06_01::ItemReviewTrendsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetItemReviewTrendsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}