Skip to main content

amazon_spapi/apis/
product_pricing_2022_05_01.rs

1/*
2 * Selling Partner API for Pricing
3 *
4 * The Selling Partner API for Pricing helps you programmatically retrieve product pricing and offer pricing information for Amazon Marketplace products.  For more information, refer to the [Product Pricing v2022-05-01 Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v2022-05-01-use-case-guide).
5 *
6 * The version of the OpenAPI document: 2022-05-01
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 [`get_competitive_summary`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetCompetitiveSummaryError {
22    Status400(models::product_pricing_2022_05_01::Errors),
23    Status403(models::product_pricing_2022_05_01::Errors),
24    Status404(models::product_pricing_2022_05_01::Errors),
25    Status429(models::product_pricing_2022_05_01::Errors),
26    Status500(models::product_pricing_2022_05_01::Errors),
27    Status503(models::product_pricing_2022_05_01::Errors),
28    UnknownValue(serde_json::Value),
29}
30
31/// struct for typed errors of method [`get_featured_offer_expected_price_batch`]
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum GetFeaturedOfferExpectedPriceBatchError {
35    Status400(models::product_pricing_2022_05_01::Errors),
36    Status401(models::product_pricing_2022_05_01::Errors),
37    Status403(models::product_pricing_2022_05_01::Errors),
38    Status404(models::product_pricing_2022_05_01::Errors),
39    Status429(models::product_pricing_2022_05_01::Errors),
40    Status500(models::product_pricing_2022_05_01::Errors),
41    Status503(models::product_pricing_2022_05_01::Errors),
42    UnknownValue(serde_json::Value),
43}
44
45
46/// Returns the competitive summary response, including featured buying options for the ASIN and `marketplaceId` combination.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.033 | 1 |  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 may 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.
47pub async fn get_competitive_summary(configuration: &configuration::Configuration, requests: models::product_pricing_2022_05_01::CompetitiveSummaryBatchRequest) -> Result<models::product_pricing_2022_05_01::CompetitiveSummaryBatchResponse, Error<GetCompetitiveSummaryError>> {
48    // add a prefix to parameters to efficiently prevent name collisions
49    let p_requests = requests;
50
51    let uri_str = format!("{}/batches/products/pricing/2022-05-01/items/competitiveSummary", configuration.base_path);
52    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
53
54    if let Some(ref user_agent) = configuration.user_agent {
55        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
56    }
57    req_builder = req_builder.json(&p_requests);
58
59    let req = req_builder.build()?;
60    let resp = configuration.client.execute(req).await?;
61
62    let status = resp.status();
63    let content_type = resp
64        .headers()
65        .get("content-type")
66        .and_then(|v| v.to_str().ok())
67        .unwrap_or("application/octet-stream");
68    let content_type = super::ContentType::from(content_type);
69
70    if !status.is_client_error() && !status.is_server_error() {
71        let content = resp.text().await?;
72        match content_type {
73            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
74            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::product_pricing_2022_05_01::CompetitiveSummaryBatchResponse`"))),
75            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::product_pricing_2022_05_01::CompetitiveSummaryBatchResponse`")))),
76        }
77    } else {
78        let content = resp.text().await?;
79        let entity: Option<GetCompetitiveSummaryError> = serde_json::from_str(&content).ok();
80        Err(Error::ResponseError(ResponseContent { status, content, entity }))
81    }
82}
83
84/// Returns the set of responses that correspond to the batched list of up to 40 requests defined in the request body. The response for each successful (HTTP status code 200) request in the set includes the computed listing price at or below which a seller can expect to become the featured offer (before applicable promotions). This is called the featured offer expected price (FOEP). Featured offer is not guaranteed because competing offers might change. Other offers might be featured based on factors such as fulfillment capabilities to a specific customer. The response to an unsuccessful request includes the available error text.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.033 | 1 |  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 may 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.
85pub async fn get_featured_offer_expected_price_batch(configuration: &configuration::Configuration, get_featured_offer_expected_price_batch_request_body: models::product_pricing_2022_05_01::GetFeaturedOfferExpectedPriceBatchRequest) -> Result<models::product_pricing_2022_05_01::GetFeaturedOfferExpectedPriceBatchResponse, Error<GetFeaturedOfferExpectedPriceBatchError>> {
86    // add a prefix to parameters to efficiently prevent name collisions
87    let p_get_featured_offer_expected_price_batch_request_body = get_featured_offer_expected_price_batch_request_body;
88
89    let uri_str = format!("{}/batches/products/pricing/2022-05-01/offer/featuredOfferExpectedPrice", configuration.base_path);
90    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
91
92    if let Some(ref user_agent) = configuration.user_agent {
93        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
94    }
95    req_builder = req_builder.json(&p_get_featured_offer_expected_price_batch_request_body);
96
97    let req = req_builder.build()?;
98    let resp = configuration.client.execute(req).await?;
99
100    let status = resp.status();
101    let content_type = resp
102        .headers()
103        .get("content-type")
104        .and_then(|v| v.to_str().ok())
105        .unwrap_or("application/octet-stream");
106    let content_type = super::ContentType::from(content_type);
107
108    if !status.is_client_error() && !status.is_server_error() {
109        let content = resp.text().await?;
110        match content_type {
111            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
112            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::product_pricing_2022_05_01::GetFeaturedOfferExpectedPriceBatchResponse`"))),
113            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::product_pricing_2022_05_01::GetFeaturedOfferExpectedPriceBatchResponse`")))),
114        }
115    } else {
116        let content = resp.text().await?;
117        let entity: Option<GetFeaturedOfferExpectedPriceBatchError> = serde_json::from_str(&content).ok();
118        Err(Error::ResponseError(ResponseContent { status, content, entity }))
119    }
120}
121