amazon_spapi/apis/
solicitations_v1.rs

1/*
2 * Selling Partner API for Solicitations
3 *
4 * With the Solicitations API you can build applications that send non-critical solicitations to buyers. You can get a list of solicitation types that are available for an order that you specify, then call an operation that sends a solicitation to the buyer for that order. Buyers cannot respond to solicitations sent by this API, and these solicitations do not appear in the Messaging section of Seller Central or in the recipient's Message Center. The Solicitations API returns responses that are formed according to the <a href=https://tools.ietf.org/html/draft-kelly-json-hal-08>JSON Hypertext Application Language</a> (HAL) standard.
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 [`create_product_review_and_seller_feedback_solicitation`]
19#[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/// struct for typed errors of method [`get_solicitation_actions_for_order`]
34#[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
49/// Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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).
50pub 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    // add a prefix to parameters to efficiently prevent name collisions
52    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
91/// Returns a list of solicitation types that are available for an order that you specify. A solicitation type is represented by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call an operation that sends a solicitation. Currently only the productReviewAndSellerFeedbackSolicitation solicitation type is available.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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).
92pub 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    // add a prefix to parameters to efficiently prevent name collisions
94    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