amazon_spapi/apis/
solicitations_v1.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateProductReviewAndSellerFeedbackSolicitationError {
22 Status400(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
23 Status403(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
24 Status404(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
25 Status413(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
26 Status415(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
27 Status429(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
28 Status500(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
29 Status503(models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse),
30 UnknownValue(serde_json::Value),
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetSolicitationActionsForOrderError {
37 Status400(models::solicitations::GetSolicitationActionsForOrderResponse),
38 Status403(models::solicitations::GetSolicitationActionsForOrderResponse),
39 Status404(models::solicitations::GetSolicitationActionsForOrderResponse),
40 Status413(models::solicitations::GetSolicitationActionsForOrderResponse),
41 Status415(models::solicitations::GetSolicitationActionsForOrderResponse),
42 Status429(models::solicitations::GetSolicitationActionsForOrderResponse),
43 Status500(models::solicitations::GetSolicitationActionsForOrderResponse),
44 Status503(models::solicitations::GetSolicitationActionsForOrderResponse),
45 UnknownValue(serde_json::Value),
46}
47
48
49pub async fn create_product_review_and_seller_feedback_solicitation(configuration: &configuration::Configuration, amazon_order_id: &str, marketplace_ids: Vec<String>) -> Result<models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse, Error<CreateProductReviewAndSellerFeedbackSolicitationError>> {
51 let p_amazon_order_id = amazon_order_id;
53 let p_marketplace_ids = marketplace_ids;
54
55 let uri_str = format!("{}/solicitations/v1/orders/{amazonOrderId}/solicitations/productReviewAndSellerFeedback", configuration.base_path, amazonOrderId=crate::apis::urlencode(p_amazon_order_id));
56 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
57
58 req_builder = match "csv" {
59 "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)>>()),
60 _ => req_builder.query(&[("marketplaceIds", &p_marketplace_ids.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
61 };
62 if let Some(ref user_agent) = configuration.user_agent {
63 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
64 }
65
66 let req = req_builder.build()?;
67 let resp = configuration.client.execute(req).await?;
68
69 let status = resp.status();
70 let content_type = resp
71 .headers()
72 .get("content-type")
73 .and_then(|v| v.to_str().ok())
74 .unwrap_or("application/octet-stream");
75 let content_type = super::ContentType::from(content_type);
76
77 if !status.is_client_error() && !status.is_server_error() {
78 let content = resp.text().await?;
79 match content_type {
80 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
81 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse`"))),
82 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::solicitations::CreateProductReviewAndSellerFeedbackSolicitationResponse`")))),
83 }
84 } else {
85 let content = resp.text().await?;
86 let entity: Option<CreateProductReviewAndSellerFeedbackSolicitationError> = serde_json::from_str(&content).ok();
87 Err(Error::ResponseError(ResponseContent { status, content, entity }))
88 }
89}
90
91pub async fn get_solicitation_actions_for_order(configuration: &configuration::Configuration, amazon_order_id: &str, marketplace_ids: Vec<String>) -> Result<models::solicitations::GetSolicitationActionsForOrderResponse, Error<GetSolicitationActionsForOrderError>> {
93 let p_amazon_order_id = amazon_order_id;
95 let p_marketplace_ids = marketplace_ids;
96
97 let uri_str = format!("{}/solicitations/v1/orders/{amazonOrderId}", configuration.base_path, amazonOrderId=crate::apis::urlencode(p_amazon_order_id));
98 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
99
100 req_builder = match "csv" {
101 "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)>>()),
102 _ => req_builder.query(&[("marketplaceIds", &p_marketplace_ids.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
103 };
104 if let Some(ref user_agent) = configuration.user_agent {
105 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
106 }
107
108 let req = req_builder.build()?;
109 let resp = configuration.client.execute(req).await?;
110
111 let status = resp.status();
112 let content_type = resp
113 .headers()
114 .get("content-type")
115 .and_then(|v| v.to_str().ok())
116 .unwrap_or("application/octet-stream");
117 let content_type = super::ContentType::from(content_type);
118
119 if !status.is_client_error() && !status.is_server_error() {
120 let content = resp.text().await?;
121 match content_type {
122 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
123 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::solicitations::GetSolicitationActionsForOrderResponse`"))),
124 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::solicitations::GetSolicitationActionsForOrderResponse`")))),
125 }
126 } else {
127 let content = resp.text().await?;
128 let entity: Option<GetSolicitationActionsForOrderError> = serde_json::from_str(&content).ok();
129 Err(Error::ResponseError(ResponseContent { status, content, entity }))
130 }
131}
132