amazon_spapi/apis/
vendor_orders_v1.rs

1/*
2 * Selling Partner API for Direct Fulfillment Orders
3 *
4 * The Selling Partner API for Direct Fulfillment Orders provides programmatic access to a direct fulfillment vendor's order data.
5 *
6 * The version of the OpenAPI document: 2021-12-28
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_order`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetOrderError {
22    Status400(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
23    Status401(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
24    Status403(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
25    Status404(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
26    Status415(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
27    Status429(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
28    Status500(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
29    Status503(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`get_orders`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetOrdersError {
37    Status400(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
38    Status403(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
39    Status404(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
40    Status415(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
41    Status429(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
42    Status500(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
43    Status503(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`submit_acknowledgement`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum SubmitAcknowledgementError {
51    Status400(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
52    Status403(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
53    Status404(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
54    Status413(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
55    Status415(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
56    Status429(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
57    Status500(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
58    Status503(models::vendor_direct_fulfillment_orders_2021_12_28::ErrorList),
59    UnknownValue(serde_json::Value),
60}
61
62
63/// Returns purchase order information for the purchaseOrderNumber that you specify.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
64pub async fn get_order(configuration: &configuration::Configuration, purchase_order_number: &str) -> Result<models::vendor_direct_fulfillment_orders_2021_12_28::Order, Error<GetOrderError>> {
65    // add a prefix to parameters to efficiently prevent name collisions
66    let p_purchase_order_number = purchase_order_number;
67
68    let uri_str = format!("{}/vendor/directFulfillment/orders/2021-12-28/purchaseOrders/{purchaseOrderNumber}", configuration.base_path, purchaseOrderNumber=crate::apis::urlencode(p_purchase_order_number));
69    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
70
71    if let Some(ref user_agent) = configuration.user_agent {
72        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73    }
74
75    let req = req_builder.build()?;
76    let resp = configuration.client.execute(req).await?;
77
78    let status = resp.status();
79    let content_type = resp
80        .headers()
81        .get("content-type")
82        .and_then(|v| v.to_str().ok())
83        .unwrap_or("application/octet-stream");
84    let content_type = super::ContentType::from(content_type);
85
86    if !status.is_client_error() && !status.is_server_error() {
87        let content = resp.text().await?;
88        match content_type {
89            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
90            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::vendor_direct_fulfillment_orders_2021_12_28::Order`"))),
91            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::vendor_direct_fulfillment_orders_2021_12_28::Order`")))),
92        }
93    } else {
94        let content = resp.text().await?;
95        let entity: Option<GetOrderError> = serde_json::from_str(&content).ok();
96        Err(Error::ResponseError(ResponseContent { status, content, entity }))
97    }
98}
99
100/// Returns a list of purchase orders created during the time frame that you specify. You define the time frame using the createdAfter and createdBefore parameters. You must use both parameters. You can choose to get only the purchase order numbers by setting the includeDetails parameter to false. In that case, the operation returns a list of purchase order numbers. You can then call the getOrder operation to return the details of a specific order.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
101pub async fn get_orders(configuration: &configuration::Configuration, created_after: String, created_before: String, ship_from_party_id: Option<&str>, status: Option<&str>, limit: Option<i64>, sort_order: Option<&str>, next_token: Option<&str>, include_details: Option<&str>) -> Result<models::vendor_direct_fulfillment_orders_2021_12_28::OrderList, Error<GetOrdersError>> {
102    // add a prefix to parameters to efficiently prevent name collisions
103    let p_created_after = created_after;
104    let p_created_before = created_before;
105    let p_ship_from_party_id = ship_from_party_id;
106    let p_status = status;
107    let p_limit = limit;
108    let p_sort_order = sort_order;
109    let p_next_token = next_token;
110    let p_include_details = include_details;
111
112    let uri_str = format!("{}/vendor/directFulfillment/orders/2021-12-28/purchaseOrders", configuration.base_path);
113    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
114
115    if let Some(ref param_value) = p_ship_from_party_id {
116        req_builder = req_builder.query(&[("shipFromPartyId", &param_value.to_string())]);
117    }
118    if let Some(ref param_value) = p_status {
119        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
120    }
121    if let Some(ref param_value) = p_limit {
122        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
123    }
124    req_builder = req_builder.query(&[("createdAfter", &p_created_after.to_string())]);
125    req_builder = req_builder.query(&[("createdBefore", &p_created_before.to_string())]);
126    if let Some(ref param_value) = p_sort_order {
127        req_builder = req_builder.query(&[("sortOrder", &param_value.to_string())]);
128    }
129    if let Some(ref param_value) = p_next_token {
130        req_builder = req_builder.query(&[("nextToken", &param_value.to_string())]);
131    }
132    if let Some(ref param_value) = p_include_details {
133        req_builder = req_builder.query(&[("includeDetails", &param_value.to_string())]);
134    }
135    if let Some(ref user_agent) = configuration.user_agent {
136        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
137    }
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::vendor_direct_fulfillment_orders_2021_12_28::OrderList`"))),
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::vendor_direct_fulfillment_orders_2021_12_28::OrderList`")))),
156        }
157    } else {
158        let content = resp.text().await?;
159        let entity: Option<GetOrdersError> = serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent { status, content, entity }))
161    }
162}
163
164/// Submits acknowledgements for one or more purchase orders.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 10 | 10 |  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 then those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).
165pub async fn submit_acknowledgement(configuration: &configuration::Configuration, body: models::vendor_direct_fulfillment_orders_2021_12_28::SubmitAcknowledgementRequest) -> Result<models::vendor_direct_fulfillment_orders_2021_12_28::TransactionId, Error<SubmitAcknowledgementError>> {
166    // add a prefix to parameters to efficiently prevent name collisions
167    let p_body = body;
168
169    let uri_str = format!("{}/vendor/directFulfillment/orders/2021-12-28/acknowledgements", 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::vendor_direct_fulfillment_orders_2021_12_28::TransactionId`"))),
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::vendor_direct_fulfillment_orders_2021_12_28::TransactionId`")))),
194        }
195    } else {
196        let content = resp.text().await?;
197        let entity: Option<SubmitAcknowledgementError> = serde_json::from_str(&content).ok();
198        Err(Error::ResponseError(ResponseContent { status, content, entity }))
199    }
200}
201