amazon_spapi/client_apis/
fba_inventory_v1.rs

1use anyhow::Result;
2
3use crate::{
4    apis::fba_inventory_api::get_inventory_summaries,
5    client::{ApiEndpoint, ApiMethod, SpapiClient},
6    models::{
7        self,
8        fba_inventory::{GetInventorySummariesResponse, InventoryItem},
9    },
10};
11
12impl SpapiClient {
13    pub async fn add_inventory(
14        &self,
15        x_amzn_idempotency_token: &str,
16        add_inventory_request_body: models::fba_inventory::AddInventoryRequest,
17    ) -> Result<models::fba_inventory::AddInventoryResponse> {
18        let configuration = self.create_configuration().await?;
19        let _ = self
20            .limiter()
21            .wait("/fba/inventory/v1/addInventory", 2.0, 2)
22            .await?;
23        let res = crate::apis::fba_inventory_api::add_inventory(
24            &configuration,
25            x_amzn_idempotency_token,
26            add_inventory_request_body,
27        )
28        .await?;
29        Ok(res)
30    }
31
32    pub async fn create_inventory_item(
33        &self,
34        create_inventory_item_request_body: models::fba_inventory::CreateInventoryItemRequest,
35    ) -> Result<models::fba_inventory::CreateInventoryItemResponse> {
36        let configuration = self.create_configuration().await?;
37        let _ = self
38            .limiter()
39            .wait("/fba/inventory/v1/createInventoryItem", 2.0, 2)
40            .await?;
41        let res = crate::apis::fba_inventory_api::create_inventory_item(
42            &configuration,
43            create_inventory_item_request_body,
44        )
45        .await?;
46        Ok(res)
47    }
48
49    pub async fn delete_inventory_item(
50        &self,
51        seller_sku: &str,
52        marketplace_id: &str,
53    ) -> Result<models::fba_inventory::DeleteInventoryItemResponse> {
54        let configuration = self.create_configuration().await?;
55        let _ = self
56            .limiter()
57            .wait("/fba/inventory/v1/deleteInventoryItem", 2.0, 2)
58            .await?;
59        let res = crate::apis::fba_inventory_api::delete_inventory_item(
60            &configuration,
61            seller_sku,
62            marketplace_id,
63        )
64        .await?;
65        Ok(res)
66    }
67
68    /// Get inventory summaries for FBA inventory
69    ///
70    /// Returns a list of inventory summaries. The summaries returned depend on the presence of the
71    /// startDateTime and sellerSkus parameters.
72    pub async fn get_inventory_summaries(
73        &self,
74        granularity_type: &str,
75        granularity_id: &str,
76        marketplace_ids: Vec<String>,
77        details: Option<bool>,
78        start_date_time: Option<String>,
79        seller_skus: Option<Vec<String>>,
80        seller_sku: Option<&str>,
81        next_token: Option<&str>,
82    ) -> Result<GetInventorySummariesResponse> {
83        let configuration = self.create_configuration().await?;
84        let _ = self
85            .limiter()
86            .wait("/fba/inventory/v1/summaries", 2.0, 2)
87            .await?;
88        let res = get_inventory_summaries(
89            &configuration,
90            granularity_type,
91            granularity_id,
92            marketplace_ids,
93            details,
94            start_date_time,
95            seller_skus,
96            seller_sku,
97            next_token,
98        )
99        .await?;
100
101        Ok(res)
102    }
103}