amazon_sp_api/models/
catalog_items.rs1use reqwest::{Method, Response};
2use crate::error_handling::Errors;
3use crate::general::{Client, CountryMarketplace};
4pub struct CatalogItems;
5impl CatalogItems {
6
7 pub async fn search_catalog_items(
27 client: &mut Client,
28 marketplace_ids: Vec<CountryMarketplace>,
29 identifiers: Option<Vec<String>>,
30 identifiers_type: Option<String>,
31 included_data: Option<Vec<String>>,
32 locale: Option<String>,
33 seller_id: Option<String>,
34 keywords: Option<Vec<String>>,
35 brand_names: Option<Vec<String>>,
36 classification_ids: Option<Vec<String>>,
37 page_size: Option<i32>,
38 page_token: Option<String>,
39 keywords_locale: Option<String>,
40 ) -> Result<Response, Errors> {
41 const URI: &str = "/catalog/2022-04-01/items";
42
43 let mut params: Vec<(String, String)> = Vec::new();
44
45 params.push(("marketplaceIds".to_string(), marketplace_ids.iter().map(|b|b.details().0.to_string()).collect::<Vec<String>>().join(",")));
46
47 if let Some(ids) = identifiers {
48 params.push(("identifiers".to_string(), ids.join(",")));
49 }
50 if let Some(id_type) = identifiers_type {
51 params.push(("identifiersType".to_string(), id_type));
52 }
53 if let Some(data) = included_data {
54 params.push(("includedData".to_string(), data.join(",")));
55 }
56 if let Some(loc) = locale {
57 params.push(("locale".to_string(), loc));
58 }
59 if let Some(sid) = seller_id {
60 params.push(("sellerId".to_string(), sid));
61 }
62 if let Some(kw) = keywords {
63 params.push(("keywords".to_string(), kw.join(",")));
64 }
65 if let Some(brands) = brand_names {
66 params.push(("brandNames".to_string(), brands.join(",")));
67 }
68 if let Some(class_ids) = classification_ids {
69 params.push(("classificationIds".to_string(), class_ids.join(",")));
70 }
71 if let Some(size) = page_size {
72 params.push(("pageSize".to_string(), size.to_string()));
73 }
74 if let Some(token) = page_token {
75 params.push(("pageToken".to_string(), token));
76 }
77 if let Some(kw_locale) = keywords_locale {
78 params.push(("keywordsLocale".to_string(), kw_locale));
79 }
80 client.make_request(URI, Method::GET, Some(params)).await
81 }
82
83 pub async fn get_catalog_item(
95 client: &mut Client,
96 asin: String,
97 marketplace_ids: Vec<CountryMarketplace>,
98 included_data: Option<Vec<String>>,
99 locale: Option<String>,
100 ) -> Result<Response, Errors> {
101 let uri = format!("/catalog/2022-04-01/items/{}", asin);
102
103 let mut params: Vec<(String, String)> = Vec::new();
104
105 params.push(("marketplaceIds".to_string(), marketplace_ids.iter().map(|b|b.details().0.to_string()).collect::<Vec<String>>().join(",")));
107
108 if let Some(data) = included_data {
110 params.push(("includedData".to_string(), data.join(",")));
111 }
112 if let Some(loc) = locale {
113 params.push(("locale".to_string(), loc));
114 }
115
116 client.make_request(&uri, Method::GET, Some(params)).await
117 }
118 }