amazon_spapi/apis/
product_fees_v0.rs

1/*
2 * Selling Partner API for Product Fees
3 *
4 * The Selling Partner API for Product Fees lets you programmatically retrieve estimated fees for a product. You can then account for those fees in your pricing.
5 *
6 * The version of the OpenAPI document: v0
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_my_fees_estimate_for_asin`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetMyFeesEstimateForAsinError {
22    Status400(models::product_fees_v0::GetMyFeesEstimateResponse),
23    Status401(models::product_fees_v0::GetMyFeesEstimateResponse),
24    Status403(models::product_fees_v0::GetMyFeesEstimateResponse),
25    Status404(models::product_fees_v0::GetMyFeesEstimateResponse),
26    Status429(models::product_fees_v0::GetMyFeesEstimateResponse),
27    Status500(models::product_fees_v0::GetMyFeesEstimateResponse),
28    Status503(models::product_fees_v0::GetMyFeesEstimateResponse),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_my_fees_estimate_for_sku`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetMyFeesEstimateForSkuError {
36    Status400(models::product_fees_v0::GetMyFeesEstimateResponse),
37    Status401(models::product_fees_v0::GetMyFeesEstimateResponse),
38    Status403(models::product_fees_v0::GetMyFeesEstimateResponse),
39    Status404(models::product_fees_v0::GetMyFeesEstimateResponse),
40    Status429(models::product_fees_v0::GetMyFeesEstimateResponse),
41    Status500(models::product_fees_v0::GetMyFeesEstimateResponse),
42    Status503(models::product_fees_v0::GetMyFeesEstimateResponse),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_my_fees_estimates`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetMyFeesEstimatesError {
50    Status400(models::product_fees_v0::GetMyFeesEstimatesErrorList),
51    Status401(models::product_fees_v0::GetMyFeesEstimatesErrorList),
52    Status403(models::product_fees_v0::GetMyFeesEstimatesErrorList),
53    Status404(models::product_fees_v0::GetMyFeesEstimatesErrorList),
54    Status429(models::product_fees_v0::GetMyFeesEstimatesErrorList),
55    Status500(models::product_fees_v0::GetMyFeesEstimatesErrorList),
56    Status503(models::product_fees_v0::GetMyFeesEstimatesErrorList),
57    UnknownValue(serde_json::Value),
58}
59
60
61/// Returns the estimated fees for the item indicated by the specified ASIN in the marketplace specified in the request body.  You can call `getMyFeesEstimateForASIN` for an item on behalf of a selling partner before the selling partner sets the item's price. The selling partner can then take estimated fees into account. Each fees request must include an original identifier. This identifier is included in the fees estimate so you can correlate a fees estimate with the original request.  **Note:** This identifier value is used to identify an estimate. Actual costs may vary. Search \"fees\" in [Seller Central](https://sellercentral.amazon.com/) and consult the store-specific fee schedule for the most up-to-date information.  **Note:** When using the `getMyFeesEstimateForASIN` operation with an ASIN, the fee estimates might be different. This is because these estimates use the item's catalog size, which might not always match the actual size of the item sent to Amazon.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 2 |  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](doc:usage-plans-and-rate-limits-in-the-sp-api).
62pub async fn get_my_fees_estimate_for_asin(configuration: &configuration::Configuration, asin: &str, body: models::product_fees_v0::GetMyFeesEstimateRequest) -> Result<models::product_fees_v0::GetMyFeesEstimateResponse, Error<GetMyFeesEstimateForAsinError>> {
63    // add a prefix to parameters to efficiently prevent name collisions
64    let p_asin = asin;
65    let p_body = body;
66
67    let uri_str = format!("{}/products/fees/v0/items/{Asin}/feesEstimate", configuration.base_path, Asin=crate::apis::urlencode(p_asin));
68    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
69
70    if let Some(ref user_agent) = configuration.user_agent {
71        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
72    }
73    req_builder = req_builder.json(&p_body);
74
75    let req = req_builder.build()?;
76    let resp = configuration.client.execute(req).await?;
77
78    let status = resp.status();
79    let content_type = resp
80        .headers()
81        .get("content-type")
82        .and_then(|v| v.to_str().ok())
83        .unwrap_or("application/octet-stream");
84    let content_type = super::ContentType::from(content_type);
85
86    if !status.is_client_error() && !status.is_server_error() {
87        let content = resp.text().await?;
88        match content_type {
89            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
90            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::product_fees_v0::GetMyFeesEstimateResponse`"))),
91            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_fees_v0::GetMyFeesEstimateResponse`")))),
92        }
93    } else {
94        let content = resp.text().await?;
95        let entity: Option<GetMyFeesEstimateForAsinError> = serde_json::from_str(&content).ok();
96        Err(Error::ResponseError(ResponseContent { status, content, entity }))
97    }
98}
99
100/// Returns the estimated fees for the item indicated by the specified seller SKU in the marketplace specified in the request body.  **Note:** The parameters associated with this operation may contain special characters that require URL encoding to call the API. To avoid errors with SKUs when encoding URLs, refer to [URL Encoding](https://developer-docs.amazon.com/sp-api/docs/url-encoding).  You can call `getMyFeesEstimateForSKU` for an item on behalf of a selling partner before the selling partner sets the item's price. The selling partner can then take any estimated fees into account. Each fees estimate request must include an original identifier. This identifier is included in the fees estimate so that you can correlate a fees estimate with the original request.  **Note:** This identifier value is used to identify an estimate. Actual costs may vary. Search \"fees\" in [Seller Central](https://sellercentral.amazon.com/) and consult the store-specific fee schedule for the most up-to-date information.  **Note:** When sellers use the `getMyFeesEstimateForSKU` operation with their `SellerSKU`, they get accurate fees based on real item measurements, but only after they've sent their items to Amazon.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 2 |  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](doc:usage-plans-and-rate-limits-in-the-sp-api).
101pub async fn get_my_fees_estimate_for_sku(configuration: &configuration::Configuration, seller_sku: &str, body: models::product_fees_v0::GetMyFeesEstimateRequest) -> Result<models::product_fees_v0::GetMyFeesEstimateResponse, Error<GetMyFeesEstimateForSkuError>> {
102    // add a prefix to parameters to efficiently prevent name collisions
103    let p_seller_sku = seller_sku;
104    let p_body = body;
105
106    let uri_str = format!("{}/products/fees/v0/listings/{SellerSKU}/feesEstimate", configuration.base_path, SellerSKU=crate::apis::urlencode(p_seller_sku));
107    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
108
109    if let Some(ref user_agent) = configuration.user_agent {
110        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
111    }
112    req_builder = req_builder.json(&p_body);
113
114    let req = req_builder.build()?;
115    let resp = configuration.client.execute(req).await?;
116
117    let status = resp.status();
118    let content_type = resp
119        .headers()
120        .get("content-type")
121        .and_then(|v| v.to_str().ok())
122        .unwrap_or("application/octet-stream");
123    let content_type = super::ContentType::from(content_type);
124
125    if !status.is_client_error() && !status.is_server_error() {
126        let content = resp.text().await?;
127        match content_type {
128            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
129            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::product_fees_v0::GetMyFeesEstimateResponse`"))),
130            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_fees_v0::GetMyFeesEstimateResponse`")))),
131        }
132    } else {
133        let content = resp.text().await?;
134        let entity: Option<GetMyFeesEstimateForSkuError> = serde_json::from_str(&content).ok();
135        Err(Error::ResponseError(ResponseContent { status, content, entity }))
136    }
137}
138
139/// Returns the estimated fees for a list of products.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.5 | 1 |  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](doc:usage-plans-and-rate-limits-in-the-sp-api).
140pub async fn get_my_fees_estimates(configuration: &configuration::Configuration, body: Vec<models::product_fees_v0::FeesEstimateByIdRequest>) -> Result<Vec<models::product_fees_v0::FeesEstimateResult>, Error<GetMyFeesEstimatesError>> {
141    // add a prefix to parameters to efficiently prevent name collisions
142    let p_body = body;
143
144    let uri_str = format!("{}/products/fees/v0/feesEstimate", configuration.base_path);
145    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
146
147    if let Some(ref user_agent) = configuration.user_agent {
148        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149    }
150    req_builder = req_builder.json(&p_body);
151
152    let req = req_builder.build()?;
153    let resp = configuration.client.execute(req).await?;
154
155    let status = resp.status();
156    let content_type = resp
157        .headers()
158        .get("content-type")
159        .and_then(|v| v.to_str().ok())
160        .unwrap_or("application/octet-stream");
161    let content_type = super::ContentType::from(content_type);
162
163    if !status.is_client_error() && !status.is_server_error() {
164        let content = resp.text().await?;
165        match content_type {
166            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
167            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::product_fees_v0::FeesEstimateResult&gt;`"))),
168            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::product_fees_v0::FeesEstimateResult&gt;`")))),
169        }
170    } else {
171        let content = resp.text().await?;
172        let entity: Option<GetMyFeesEstimatesError> = serde_json::from_str(&content).ok();
173        Err(Error::ResponseError(ResponseContent { status, content, entity }))
174    }
175}
176