1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetBillOfLadingError {
22 Status400(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
23 Status401(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
24 Status403(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
25 Status404(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
26 Status429(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
27 Status500(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
28 Status503(models::fulfillment_inbound_v0::GetBillOfLadingResponse),
29 UnknownValue(serde_json::Value),
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetLabelsError {
36 Status400(models::fulfillment_inbound_v0::GetLabelsResponse),
37 Status401(models::fulfillment_inbound_v0::GetLabelsResponse),
38 Status403(models::fulfillment_inbound_v0::GetLabelsResponse),
39 Status404(models::fulfillment_inbound_v0::GetLabelsResponse),
40 Status429(models::fulfillment_inbound_v0::GetLabelsResponse),
41 Status500(models::fulfillment_inbound_v0::GetLabelsResponse),
42 Status503(models::fulfillment_inbound_v0::GetLabelsResponse),
43 UnknownValue(serde_json::Value),
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetPrepInstructionsError {
50 Status400(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
51 Status401(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
52 Status403(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
53 Status404(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
54 Status429(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
55 Status500(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
56 Status503(models::fulfillment_inbound_v0::GetPrepInstructionsResponse),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetShipmentItemsError {
64 Status400(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
65 Status401(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
66 Status403(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
67 Status404(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
68 Status429(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
69 Status500(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
70 Status503(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
71 UnknownValue(serde_json::Value),
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetShipmentItemsByShipmentIdError {
78 Status400(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
79 Status401(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
80 Status403(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
81 Status404(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
82 Status429(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
83 Status500(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
84 Status503(models::fulfillment_inbound_v0::GetShipmentItemsResponse),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetShipmentsError {
92 Status400(models::fulfillment_inbound_v0::GetShipmentsResponse),
93 Status401(models::fulfillment_inbound_v0::GetShipmentsResponse),
94 Status403(models::fulfillment_inbound_v0::GetShipmentsResponse),
95 Status404(models::fulfillment_inbound_v0::GetShipmentsResponse),
96 Status429(models::fulfillment_inbound_v0::GetShipmentsResponse),
97 Status500(models::fulfillment_inbound_v0::GetShipmentsResponse),
98 Status503(models::fulfillment_inbound_v0::GetShipmentsResponse),
99 UnknownValue(serde_json::Value),
100}
101
102
103pub async fn get_bill_of_lading(configuration: &configuration::Configuration, shipment_id: &str) -> Result<models::fulfillment_inbound_v0::GetBillOfLadingResponse, Error<GetBillOfLadingError>> {
105 let p_shipment_id = shipment_id;
107
108 let uri_str = format!("{}/fba/inbound/v0/shipments/{shipmentId}/billOfLading", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
109 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
110
111 if let Some(ref user_agent) = configuration.user_agent {
112 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
113 }
114
115 let req = req_builder.build()?;
116 let resp = configuration.client.execute(req).await?;
117
118 let status = resp.status();
119 let content_type = resp
120 .headers()
121 .get("content-type")
122 .and_then(|v| v.to_str().ok())
123 .unwrap_or("application/octet-stream");
124 let content_type = super::ContentType::from(content_type);
125
126 if !status.is_client_error() && !status.is_server_error() {
127 let content = resp.text().await?;
128 match content_type {
129 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
130 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fulfillment_inbound_v0::GetBillOfLadingResponse`"))),
131 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::fulfillment_inbound_v0::GetBillOfLadingResponse`")))),
132 }
133 } else {
134 let content = resp.text().await?;
135 let entity: Option<GetBillOfLadingError> = serde_json::from_str(&content).ok();
136 Err(Error::ResponseError(ResponseContent { status, content, entity }))
137 }
138}
139
140pub async fn get_labels(configuration: &configuration::Configuration, shipment_id: &str, page_type: &str, label_type: &str, number_of_packages: Option<i32>, package_labels_to_print: Option<Vec<String>>, number_of_pallets: Option<i32>, page_size: Option<i32>, page_start_index: Option<i32>) -> Result<models::fulfillment_inbound_v0::GetLabelsResponse, Error<GetLabelsError>> {
142 let p_shipment_id = shipment_id;
144 let p_page_type = page_type;
145 let p_label_type = label_type;
146 let p_number_of_packages = number_of_packages;
147 let p_package_labels_to_print = package_labels_to_print;
148 let p_number_of_pallets = number_of_pallets;
149 let p_page_size = page_size;
150 let p_page_start_index = page_start_index;
151
152 let uri_str = format!("{}/fba/inbound/v0/shipments/{shipmentId}/labels", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
153 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
154
155 req_builder = req_builder.query(&[("PageType", &p_page_type.to_string())]);
156 req_builder = req_builder.query(&[("LabelType", &p_label_type.to_string())]);
157 if let Some(ref param_value) = p_number_of_packages {
158 req_builder = req_builder.query(&[("NumberOfPackages", ¶m_value.to_string())]);
159 }
160 if let Some(ref param_value) = p_package_labels_to_print {
161 req_builder = match "csv" {
162 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("PackageLabelsToPrint".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
163 _ => req_builder.query(&[("PackageLabelsToPrint", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
164 };
165 }
166 if let Some(ref param_value) = p_number_of_pallets {
167 req_builder = req_builder.query(&[("NumberOfPallets", ¶m_value.to_string())]);
168 }
169 if let Some(ref param_value) = p_page_size {
170 req_builder = req_builder.query(&[("PageSize", ¶m_value.to_string())]);
171 }
172 if let Some(ref param_value) = p_page_start_index {
173 req_builder = req_builder.query(&[("PageStartIndex", ¶m_value.to_string())]);
174 }
175 if let Some(ref user_agent) = configuration.user_agent {
176 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
177 }
178
179 let req = req_builder.build()?;
180 let resp = configuration.client.execute(req).await?;
181
182 let status = resp.status();
183 let content_type = resp
184 .headers()
185 .get("content-type")
186 .and_then(|v| v.to_str().ok())
187 .unwrap_or("application/octet-stream");
188 let content_type = super::ContentType::from(content_type);
189
190 if !status.is_client_error() && !status.is_server_error() {
191 let content = resp.text().await?;
192 match content_type {
193 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
194 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fulfillment_inbound_v0::GetLabelsResponse`"))),
195 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::fulfillment_inbound_v0::GetLabelsResponse`")))),
196 }
197 } else {
198 let content = resp.text().await?;
199 let entity: Option<GetLabelsError> = serde_json::from_str(&content).ok();
200 Err(Error::ResponseError(ResponseContent { status, content, entity }))
201 }
202}
203
204pub async fn get_prep_instructions(configuration: &configuration::Configuration, ship_to_country_code: &str, seller_sku_list: Option<Vec<String>>, asin_list: Option<Vec<String>>) -> Result<models::fulfillment_inbound_v0::GetPrepInstructionsResponse, Error<GetPrepInstructionsError>> {
206 let p_ship_to_country_code = ship_to_country_code;
208 let p_seller_sku_list = seller_sku_list;
209 let p_asin_list = asin_list;
210
211 let uri_str = format!("{}/fba/inbound/v0/prepInstructions", configuration.base_path);
212 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
213
214 req_builder = req_builder.query(&[("ShipToCountryCode", &p_ship_to_country_code.to_string())]);
215 if let Some(ref param_value) = p_seller_sku_list {
216 req_builder = match "csv" {
217 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("SellerSKUList".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
218 _ => req_builder.query(&[("SellerSKUList", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
219 };
220 }
221 if let Some(ref param_value) = p_asin_list {
222 req_builder = match "csv" {
223 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ASINList".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
224 _ => req_builder.query(&[("ASINList", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
225 };
226 }
227 if let Some(ref user_agent) = configuration.user_agent {
228 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
229 }
230
231 let req = req_builder.build()?;
232 let resp = configuration.client.execute(req).await?;
233
234 let status = resp.status();
235 let content_type = resp
236 .headers()
237 .get("content-type")
238 .and_then(|v| v.to_str().ok())
239 .unwrap_or("application/octet-stream");
240 let content_type = super::ContentType::from(content_type);
241
242 if !status.is_client_error() && !status.is_server_error() {
243 let content = resp.text().await?;
244 match content_type {
245 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
246 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fulfillment_inbound_v0::GetPrepInstructionsResponse`"))),
247 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::fulfillment_inbound_v0::GetPrepInstructionsResponse`")))),
248 }
249 } else {
250 let content = resp.text().await?;
251 let entity: Option<GetPrepInstructionsError> = serde_json::from_str(&content).ok();
252 Err(Error::ResponseError(ResponseContent { status, content, entity }))
253 }
254}
255
256pub async fn get_shipment_items(configuration: &configuration::Configuration, query_type: &str, marketplace_id: &str, last_updated_after: Option<String>, last_updated_before: Option<String>, next_token: Option<&str>) -> Result<models::fulfillment_inbound_v0::GetShipmentItemsResponse, Error<GetShipmentItemsError>> {
258 let p_query_type = query_type;
260 let p_marketplace_id = marketplace_id;
261 let p_last_updated_after = last_updated_after;
262 let p_last_updated_before = last_updated_before;
263 let p_next_token = next_token;
264
265 let uri_str = format!("{}/fba/inbound/v0/shipmentItems", configuration.base_path);
266 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
267
268 if let Some(ref param_value) = p_last_updated_after {
269 req_builder = req_builder.query(&[("LastUpdatedAfter", ¶m_value.to_string())]);
270 }
271 if let Some(ref param_value) = p_last_updated_before {
272 req_builder = req_builder.query(&[("LastUpdatedBefore", ¶m_value.to_string())]);
273 }
274 req_builder = req_builder.query(&[("QueryType", &p_query_type.to_string())]);
275 if let Some(ref param_value) = p_next_token {
276 req_builder = req_builder.query(&[("NextToken", ¶m_value.to_string())]);
277 }
278 req_builder = req_builder.query(&[("MarketplaceId", &p_marketplace_id.to_string())]);
279 if let Some(ref user_agent) = configuration.user_agent {
280 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
281 }
282
283 let req = req_builder.build()?;
284 let resp = configuration.client.execute(req).await?;
285
286 let status = resp.status();
287 let content_type = resp
288 .headers()
289 .get("content-type")
290 .and_then(|v| v.to_str().ok())
291 .unwrap_or("application/octet-stream");
292 let content_type = super::ContentType::from(content_type);
293
294 if !status.is_client_error() && !status.is_server_error() {
295 let content = resp.text().await?;
296 match content_type {
297 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
298 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fulfillment_inbound_v0::GetShipmentItemsResponse`"))),
299 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::fulfillment_inbound_v0::GetShipmentItemsResponse`")))),
300 }
301 } else {
302 let content = resp.text().await?;
303 let entity: Option<GetShipmentItemsError> = serde_json::from_str(&content).ok();
304 Err(Error::ResponseError(ResponseContent { status, content, entity }))
305 }
306}
307
308pub async fn get_shipment_items_by_shipment_id(configuration: &configuration::Configuration, shipment_id: &str, marketplace_id: Option<&str>) -> Result<models::fulfillment_inbound_v0::GetShipmentItemsResponse, Error<GetShipmentItemsByShipmentIdError>> {
310 let p_shipment_id = shipment_id;
312 let p_marketplace_id = marketplace_id;
313
314 let uri_str = format!("{}/fba/inbound/v0/shipments/{shipmentId}/items", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
315 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
316
317 if let Some(ref param_value) = p_marketplace_id {
318 req_builder = req_builder.query(&[("MarketplaceId", ¶m_value.to_string())]);
319 }
320 if let Some(ref user_agent) = configuration.user_agent {
321 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
322 }
323
324 let req = req_builder.build()?;
325 let resp = configuration.client.execute(req).await?;
326
327 let status = resp.status();
328 let content_type = resp
329 .headers()
330 .get("content-type")
331 .and_then(|v| v.to_str().ok())
332 .unwrap_or("application/octet-stream");
333 let content_type = super::ContentType::from(content_type);
334
335 if !status.is_client_error() && !status.is_server_error() {
336 let content = resp.text().await?;
337 match content_type {
338 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
339 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fulfillment_inbound_v0::GetShipmentItemsResponse`"))),
340 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::fulfillment_inbound_v0::GetShipmentItemsResponse`")))),
341 }
342 } else {
343 let content = resp.text().await?;
344 let entity: Option<GetShipmentItemsByShipmentIdError> = serde_json::from_str(&content).ok();
345 Err(Error::ResponseError(ResponseContent { status, content, entity }))
346 }
347}
348
349pub async fn get_shipments(configuration: &configuration::Configuration, query_type: &str, marketplace_id: &str, shipment_status_list: Option<Vec<String>>, shipment_id_list: Option<Vec<String>>, last_updated_after: Option<String>, last_updated_before: Option<String>, next_token: Option<&str>) -> Result<models::fulfillment_inbound_v0::GetShipmentsResponse, Error<GetShipmentsError>> {
351 let p_query_type = query_type;
353 let p_marketplace_id = marketplace_id;
354 let p_shipment_status_list = shipment_status_list;
355 let p_shipment_id_list = shipment_id_list;
356 let p_last_updated_after = last_updated_after;
357 let p_last_updated_before = last_updated_before;
358 let p_next_token = next_token;
359
360 let uri_str = format!("{}/fba/inbound/v0/shipments", configuration.base_path);
361 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
362
363 if let Some(ref param_value) = p_shipment_status_list {
364 req_builder = match "csv" {
365 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ShipmentStatusList".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
366 _ => req_builder.query(&[("ShipmentStatusList", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
367 };
368 }
369 if let Some(ref param_value) = p_shipment_id_list {
370 req_builder = match "csv" {
371 "multi" => req_builder.query(¶m_value.into_iter().map(|p| ("ShipmentIdList".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
372 _ => req_builder.query(&[("ShipmentIdList", ¶m_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
373 };
374 }
375 if let Some(ref param_value) = p_last_updated_after {
376 req_builder = req_builder.query(&[("LastUpdatedAfter", ¶m_value.to_string())]);
377 }
378 if let Some(ref param_value) = p_last_updated_before {
379 req_builder = req_builder.query(&[("LastUpdatedBefore", ¶m_value.to_string())]);
380 }
381 req_builder = req_builder.query(&[("QueryType", &p_query_type.to_string())]);
382 if let Some(ref param_value) = p_next_token {
383 req_builder = req_builder.query(&[("NextToken", ¶m_value.to_string())]);
384 }
385 req_builder = req_builder.query(&[("MarketplaceId", &p_marketplace_id.to_string())]);
386 if let Some(ref user_agent) = configuration.user_agent {
387 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
388 }
389
390 let req = req_builder.build()?;
391 let resp = configuration.client.execute(req).await?;
392
393 let status = resp.status();
394 let content_type = resp
395 .headers()
396 .get("content-type")
397 .and_then(|v| v.to_str().ok())
398 .unwrap_or("application/octet-stream");
399 let content_type = super::ContentType::from(content_type);
400
401 if !status.is_client_error() && !status.is_server_error() {
402 let content = resp.text().await?;
403 match content_type {
404 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
405 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::fulfillment_inbound_v0::GetShipmentsResponse`"))),
406 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::fulfillment_inbound_v0::GetShipmentsResponse`")))),
407 }
408 } else {
409 let content = resp.text().await?;
410 let entity: Option<GetShipmentsError> = serde_json::from_str(&content).ok();
411 Err(Error::ResponseError(ResponseContent { status, content, entity }))
412 }
413}
414