amazon_spapi/apis/
shipment_invoicing_v0.rs

1/*
2 * Selling Partner API for Shipment Invoicing
3 *
4 * The Selling Partner API for Shipment Invoicing helps you programmatically retrieve shipment invoice information in the Brazil marketplace for a selling partner’s Fulfillment by Amazon (FBA) orders.
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 [`get_invoice_status`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetInvoiceStatusError {
22    Status400(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
23    Status401(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
24    Status403(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
25    Status404(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
26    Status415(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
27    Status429(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
28    Status500(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
29    Status503(models::shipment_invoicing_v0::GetInvoiceStatusResponse),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`get_shipment_details`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetShipmentDetailsError {
37    Status400(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
38    Status401(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
39    Status403(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
40    Status404(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
41    Status415(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
42    Status429(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
43    Status500(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
44    Status503(models::shipment_invoicing_v0::GetShipmentDetailsResponse),
45    UnknownValue(serde_json::Value),
46}
47
48/// struct for typed errors of method [`submit_invoice`]
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum SubmitInvoiceError {
52    Status400(models::shipment_invoicing_v0::SubmitInvoiceResponse),
53    Status401(models::shipment_invoicing_v0::SubmitInvoiceResponse),
54    Status403(models::shipment_invoicing_v0::SubmitInvoiceResponse),
55    Status404(models::shipment_invoicing_v0::SubmitInvoiceResponse),
56    Status415(models::shipment_invoicing_v0::SubmitInvoiceResponse),
57    Status429(models::shipment_invoicing_v0::SubmitInvoiceResponse),
58    Status500(models::shipment_invoicing_v0::SubmitInvoiceResponse),
59    Status503(models::shipment_invoicing_v0::SubmitInvoiceResponse),
60    UnknownValue(serde_json::Value),
61}
62
63
64/// Returns the invoice status for the shipment you specify.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1.133 | 25 |  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 than 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).
65pub async fn get_invoice_status(configuration: &configuration::Configuration, shipment_id: &str) -> Result<models::shipment_invoicing_v0::GetInvoiceStatusResponse, Error<GetInvoiceStatusError>> {
66    // add a prefix to parameters to efficiently prevent name collisions
67    let p_shipment_id = shipment_id;
68
69    let uri_str = format!("{}/fba/outbound/brazil/v0/shipments/{shipmentId}/invoice/status", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
70    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
71
72    if let Some(ref user_agent) = configuration.user_agent {
73        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
74    }
75
76    let req = req_builder.build()?;
77    let resp = configuration.client.execute(req).await?;
78
79    let status = resp.status();
80    let content_type = resp
81        .headers()
82        .get("content-type")
83        .and_then(|v| v.to_str().ok())
84        .unwrap_or("application/octet-stream");
85    let content_type = super::ContentType::from(content_type);
86
87    if !status.is_client_error() && !status.is_server_error() {
88        let content = resp.text().await?;
89        match content_type {
90            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
91            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::shipment_invoicing_v0::GetInvoiceStatusResponse`"))),
92            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::shipment_invoicing_v0::GetInvoiceStatusResponse`")))),
93        }
94    } else {
95        let content = resp.text().await?;
96        let entity: Option<GetInvoiceStatusError> = serde_json::from_str(&content).ok();
97        Err(Error::ResponseError(ResponseContent { status, content, entity }))
98    }
99}
100
101/// Returns the shipment details required to issue an invoice for the specified shipment.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1.133 | 25 |  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 than 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).
102pub async fn get_shipment_details(configuration: &configuration::Configuration, shipment_id: &str) -> Result<models::shipment_invoicing_v0::GetShipmentDetailsResponse, Error<GetShipmentDetailsError>> {
103    // add a prefix to parameters to efficiently prevent name collisions
104    let p_shipment_id = shipment_id;
105
106    let uri_str = format!("{}/fba/outbound/brazil/v0/shipments/{shipmentId}", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
107    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
108
109    if let Some(ref user_agent) = configuration.user_agent {
110        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
111    }
112
113    let req = req_builder.build()?;
114    let resp = configuration.client.execute(req).await?;
115
116    let status = resp.status();
117    let content_type = resp
118        .headers()
119        .get("content-type")
120        .and_then(|v| v.to_str().ok())
121        .unwrap_or("application/octet-stream");
122    let content_type = super::ContentType::from(content_type);
123
124    if !status.is_client_error() && !status.is_server_error() {
125        let content = resp.text().await?;
126        match content_type {
127            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
128            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::shipment_invoicing_v0::GetShipmentDetailsResponse`"))),
129            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::shipment_invoicing_v0::GetShipmentDetailsResponse`")))),
130        }
131    } else {
132        let content = resp.text().await?;
133        let entity: Option<GetShipmentDetailsError> = serde_json::from_str(&content).ok();
134        Err(Error::ResponseError(ResponseContent { status, content, entity }))
135    }
136}
137
138/// Submits a shipment invoice document for a given shipment.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1.133 | 25 |  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 than 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).
139pub async fn submit_invoice(configuration: &configuration::Configuration, shipment_id: &str, body: models::shipment_invoicing_v0::SubmitInvoiceRequest) -> Result<models::shipment_invoicing_v0::SubmitInvoiceResponse, Error<SubmitInvoiceError>> {
140    // add a prefix to parameters to efficiently prevent name collisions
141    let p_shipment_id = shipment_id;
142    let p_body = body;
143
144    let uri_str = format!("{}/fba/outbound/brazil/v0/shipments/{shipmentId}/invoice", configuration.base_path, shipmentId=crate::apis::urlencode(p_shipment_id));
145    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
146
147    if let Some(ref user_agent) = configuration.user_agent {
148        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
149    }
150    req_builder = req_builder.json(&p_body);
151
152    let req = req_builder.build()?;
153    let resp = configuration.client.execute(req).await?;
154
155    let status = resp.status();
156    let content_type = resp
157        .headers()
158        .get("content-type")
159        .and_then(|v| v.to_str().ok())
160        .unwrap_or("application/octet-stream");
161    let content_type = super::ContentType::from(content_type);
162
163    if !status.is_client_error() && !status.is_server_error() {
164        let content = resp.text().await?;
165        match content_type {
166            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
167            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::shipment_invoicing_v0::SubmitInvoiceResponse`"))),
168            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::shipment_invoicing_v0::SubmitInvoiceResponse`")))),
169        }
170    } else {
171        let content = resp.text().await?;
172        let entity: Option<SubmitInvoiceError> = serde_json::from_str(&content).ok();
173        Err(Error::ResponseError(ResponseContent { status, content, entity }))
174    }
175}
176