amazon_spapi/apis/
fba_inbound_api.rs

1/*
2 * Selling Partner API for FBA Inbound Eligibilty
3 *
4 * With the FBA Inbound Eligibility API, you can build applications that let sellers get eligibility previews for items before shipping them to Amazon's fulfillment centers. With this API you can find out if an item is eligible for inbound shipment to Amazon's fulfillment centers in a specific marketplace. You can also find out if an item is eligible for using the manufacturer barcode for FBA inventory tracking. Sellers can use this information to inform their decisions about which items to ship Amazon's fulfillment centers.
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 [`get_item_eligibility_preview`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetItemEligibilityPreviewError {
22    Status400(models::fba_inbound::GetItemEligibilityPreviewResponse),
23    Status401(models::fba_inbound::GetItemEligibilityPreviewResponse),
24    Status403(models::fba_inbound::GetItemEligibilityPreviewResponse),
25    Status404(models::fba_inbound::GetItemEligibilityPreviewResponse),
26    Status429(models::fba_inbound::GetItemEligibilityPreviewResponse),
27    Status500(models::fba_inbound::GetItemEligibilityPreviewResponse),
28    Status503(models::fba_inbound::GetItemEligibilityPreviewResponse),
29    UnknownValue(serde_json::Value),
30}
31
32
33/// This operation gets an eligibility preview for an item that you specify. You can specify the type of eligibility preview that you want (INBOUND or COMMINGLING). For INBOUND previews, you can specify the marketplace in which you want to determine the item's eligibility.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 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](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
34pub async fn get_item_eligibility_preview(configuration: &configuration::Configuration, asin: &str, program: &str, marketplace_ids: Option<Vec<String>>) -> Result<models::fba_inbound::GetItemEligibilityPreviewResponse, Error<GetItemEligibilityPreviewError>> {
35    // add a prefix to parameters to efficiently prevent name collisions
36    let p_asin = asin;
37    let p_program = program;
38    let p_marketplace_ids = marketplace_ids;
39
40    let uri_str = format!("{}/fba/inbound/v1/eligibility/itemPreview", configuration.base_path);
41    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
42
43    if let Some(ref param_value) = p_marketplace_ids {
44        req_builder = match "csv" {
45            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("marketplaceIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
46            _ => req_builder.query(&[("marketplaceIds", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
47        };
48    }
49    req_builder = req_builder.query(&[("asin", &p_asin.to_string())]);
50    req_builder = req_builder.query(&[("program", &p_program.to_string())]);
51    if let Some(ref user_agent) = configuration.user_agent {
52        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
53    }
54
55    let req = req_builder.build()?;
56    let resp = configuration.client.execute(req).await?;
57
58    let status = resp.status();
59    let content_type = resp
60        .headers()
61        .get("content-type")
62        .and_then(|v| v.to_str().ok())
63        .unwrap_or("application/octet-stream");
64    let content_type = super::ContentType::from(content_type);
65
66    if !status.is_client_error() && !status.is_server_error() {
67        let content = resp.text().await?;
68        match content_type {
69            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
70            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fba_inbound::GetItemEligibilityPreviewResponse`"))),
71            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::fba_inbound::GetItemEligibilityPreviewResponse`")))),
72        }
73    } else {
74        let content = resp.text().await?;
75        let entity: Option<GetItemEligibilityPreviewError> = serde_json::from_str(&content).ok();
76        Err(Error::ResponseError(ResponseContent { status, content, entity }))
77    }
78}
79