amazon_spapi/apis/
merchant_fulfillment_v0.rs

1/*
2 * Selling Partner API for Merchant Fulfillment
3 *
4 * With the Selling Partner API for Merchant Fulfillment, you can build applications that sellers can use to purchase shipping for non-Prime and Prime orders using Amazon's Buy Shipping Services.
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 [`cancel_shipment`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CancelShipmentError {
22    Status400(models::merchant_fulfillment_v0::CancelShipmentResponse),
23    Status401(models::merchant_fulfillment_v0::CancelShipmentResponse),
24    Status403(models::merchant_fulfillment_v0::CancelShipmentResponse),
25    Status404(models::merchant_fulfillment_v0::CancelShipmentResponse),
26    Status429(models::merchant_fulfillment_v0::CancelShipmentResponse),
27    Status500(models::merchant_fulfillment_v0::CancelShipmentResponse),
28    Status503(models::merchant_fulfillment_v0::CancelShipmentResponse),
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`create_shipment`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum CreateShipmentError {
36    Status400(models::merchant_fulfillment_v0::CreateShipmentResponse),
37    Status401(models::merchant_fulfillment_v0::CreateShipmentResponse),
38    Status403(models::merchant_fulfillment_v0::CreateShipmentResponse),
39    Status404(models::merchant_fulfillment_v0::CreateShipmentResponse),
40    Status429(models::merchant_fulfillment_v0::CreateShipmentResponse),
41    Status500(models::merchant_fulfillment_v0::CreateShipmentResponse),
42    Status503(models::merchant_fulfillment_v0::CreateShipmentResponse),
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_additional_seller_inputs`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetAdditionalSellerInputsError {
50    Status400(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
51    Status401(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
52    Status403(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
53    Status404(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
54    Status429(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
55    Status500(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
56    Status503(models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse),
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_eligible_shipment_services`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetEligibleShipmentServicesError {
64    Status400(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
65    Status401(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
66    Status403(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
67    Status404(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
68    Status429(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
69    Status500(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
70    Status503(models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_shipment`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetShipmentError {
78    Status400(models::merchant_fulfillment_v0::GetShipmentResponse),
79    Status401(models::merchant_fulfillment_v0::GetShipmentResponse),
80    Status403(models::merchant_fulfillment_v0::GetShipmentResponse),
81    Status404(models::merchant_fulfillment_v0::GetShipmentResponse),
82    Status429(models::merchant_fulfillment_v0::GetShipmentResponse),
83    Status500(models::merchant_fulfillment_v0::GetShipmentResponse),
84    Status503(models::merchant_fulfillment_v0::GetShipmentResponse),
85    UnknownValue(serde_json::Value),
86}
87
88
89/// Cancel the shipment indicated by the specified shipment identifier.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that are applied to the requested operation when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the SP-API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
90pub async fn cancel_shipment(configuration: &configuration::Configuration, shipment_id: &str) -> Result<models::merchant_fulfillment_v0::CancelShipmentResponse, Error<CancelShipmentError>> {
91    // add a prefix to parameters to efficiently prevent name collisions
92    let p_shipment_id = shipment_id;
93
94    let uri_str = format!("{}/mfn/v0/shipments/{shipmentId}", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
95    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
96
97    if let Some(ref user_agent) = configuration.user_agent {
98        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99    }
100
101    let req = req_builder.build()?;
102    let resp = configuration.client.execute(req).await?;
103
104    let status = resp.status();
105    let content_type = resp
106        .headers()
107        .get("content-type")
108        .and_then(|v| v.to_str().ok())
109        .unwrap_or("application/octet-stream");
110    let content_type = super::ContentType::from(content_type);
111
112    if !status.is_client_error() && !status.is_server_error() {
113        let content = resp.text().await?;
114        match content_type {
115            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
116            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::merchant_fulfillment_v0::CancelShipmentResponse`"))),
117            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::merchant_fulfillment_v0::CancelShipmentResponse`")))),
118        }
119    } else {
120        let content = resp.text().await?;
121        let entity: Option<CancelShipmentError> = serde_json::from_str(&content).ok();
122        Err(Error::ResponseError(ResponseContent { status, content, entity }))
123    }
124}
125
126/// Create a shipment with the information provided.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 2 | 2 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that are applied to the requested operation when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the SP-API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
127pub async fn create_shipment(configuration: &configuration::Configuration, body: models::merchant_fulfillment_v0::CreateShipmentRequest) -> Result<models::merchant_fulfillment_v0::CreateShipmentResponse, Error<CreateShipmentError>> {
128    // add a prefix to parameters to efficiently prevent name collisions
129    let p_body = body;
130
131    let uri_str = format!("{}/mfn/v0/shipments", configuration.base_path);
132    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
133
134    if let Some(ref user_agent) = configuration.user_agent {
135        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
136    }
137    req_builder = req_builder.json(&p_body);
138
139    let req = req_builder.build()?;
140    let resp = configuration.client.execute(req).await?;
141
142    let status = resp.status();
143    let content_type = resp
144        .headers()
145        .get("content-type")
146        .and_then(|v| v.to_str().ok())
147        .unwrap_or("application/octet-stream");
148    let content_type = super::ContentType::from(content_type);
149
150    if !status.is_client_error() && !status.is_server_error() {
151        let content = resp.text().await?;
152        match content_type {
153            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
154            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::merchant_fulfillment_v0::CreateShipmentResponse`"))),
155            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::merchant_fulfillment_v0::CreateShipmentResponse`")))),
156        }
157    } else {
158        let content = resp.text().await?;
159        let entity: Option<CreateShipmentError> = serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent { status, content, entity }))
161    }
162}
163
164/// Gets a list of additional seller inputs required for a ship method. This is generally used for international shipping.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that are applied to the requested operation when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the SP-API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
165pub async fn get_additional_seller_inputs(configuration: &configuration::Configuration, body: models::merchant_fulfillment_v0::GetAdditionalSellerInputsRequest) -> Result<models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse, Error<GetAdditionalSellerInputsError>> {
166    // add a prefix to parameters to efficiently prevent name collisions
167    let p_body = body;
168
169    let uri_str = format!("{}/mfn/v0/additionalSellerInputs", configuration.base_path);
170    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
171
172    if let Some(ref user_agent) = configuration.user_agent {
173        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
174    }
175    req_builder = req_builder.json(&p_body);
176
177    let req = req_builder.build()?;
178    let resp = configuration.client.execute(req).await?;
179
180    let status = resp.status();
181    let content_type = resp
182        .headers()
183        .get("content-type")
184        .and_then(|v| v.to_str().ok())
185        .unwrap_or("application/octet-stream");
186    let content_type = super::ContentType::from(content_type);
187
188    if !status.is_client_error() && !status.is_server_error() {
189        let content = resp.text().await?;
190        match content_type {
191            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
192            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse`"))),
193            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::merchant_fulfillment_v0::GetAdditionalSellerInputsResponse`")))),
194        }
195    } else {
196        let content = resp.text().await?;
197        let entity: Option<GetAdditionalSellerInputsError> = serde_json::from_str(&content).ok();
198        Err(Error::ResponseError(ResponseContent { status, content, entity }))
199    }
200}
201
202/// Returns a list of shipping service offers that satisfy the specified shipment request details.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 6 | 12 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that are applied to the requested operation when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the SP-API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
203pub async fn get_eligible_shipment_services(configuration: &configuration::Configuration, body: models::merchant_fulfillment_v0::GetEligibleShipmentServicesRequest) -> Result<models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse, Error<GetEligibleShipmentServicesError>> {
204    // add a prefix to parameters to efficiently prevent name collisions
205    let p_body = body;
206
207    let uri_str = format!("{}/mfn/v0/eligibleShippingServices", configuration.base_path);
208    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
209
210    if let Some(ref user_agent) = configuration.user_agent {
211        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
212    }
213    req_builder = req_builder.json(&p_body);
214
215    let req = req_builder.build()?;
216    let resp = configuration.client.execute(req).await?;
217
218    let status = resp.status();
219    let content_type = resp
220        .headers()
221        .get("content-type")
222        .and_then(|v| v.to_str().ok())
223        .unwrap_or("application/octet-stream");
224    let content_type = super::ContentType::from(content_type);
225
226    if !status.is_client_error() && !status.is_server_error() {
227        let content = resp.text().await?;
228        match content_type {
229            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
230            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse`"))),
231            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::merchant_fulfillment_v0::GetEligibleShipmentServicesResponse`")))),
232        }
233    } else {
234        let content = resp.text().await?;
235        let entity: Option<GetEligibleShipmentServicesError> = serde_json::from_str(&content).ok();
236        Err(Error::ResponseError(ResponseContent { status, content, entity }))
237    }
238}
239
240/// Returns the shipment information for an existing shipment.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 1 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that are applied to the requested operation when available. The preceding table indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may have higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the SP-API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
241pub async fn get_shipment(configuration: &configuration::Configuration, shipment_id: &str) -> Result<models::merchant_fulfillment_v0::GetShipmentResponse, Error<GetShipmentError>> {
242    // add a prefix to parameters to efficiently prevent name collisions
243    let p_shipment_id = shipment_id;
244
245    let uri_str = format!("{}/mfn/v0/shipments/{shipmentId}", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
246    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
247
248    if let Some(ref user_agent) = configuration.user_agent {
249        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
250    }
251
252    let req = req_builder.build()?;
253    let resp = configuration.client.execute(req).await?;
254
255    let status = resp.status();
256    let content_type = resp
257        .headers()
258        .get("content-type")
259        .and_then(|v| v.to_str().ok())
260        .unwrap_or("application/octet-stream");
261    let content_type = super::ContentType::from(content_type);
262
263    if !status.is_client_error() && !status.is_server_error() {
264        let content = resp.text().await?;
265        match content_type {
266            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
267            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::merchant_fulfillment_v0::GetShipmentResponse`"))),
268            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::merchant_fulfillment_v0::GetShipmentResponse`")))),
269        }
270    } else {
271        let content = resp.text().await?;
272        let entity: Option<GetShipmentError> = serde_json::from_str(&content).ok();
273        Err(Error::ResponseError(ResponseContent { status, content, entity }))
274    }
275}
276