amazon_spapi/apis/
vendor_direct_fulfillment_transactions_v1.rs

1/*
2 * Selling Partner API for Direct Fulfillment Transaction Status
3 *
4 * The Selling Partner API for Direct Fulfillment Transaction Status provides programmatic access to a direct fulfillment vendor's transaction status.
5 *
6 * The version of the OpenAPI document: v1
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_transaction_status`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetTransactionStatusError {
22    Status400(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
23    Status401(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
24    Status403(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
25    Status404(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
26    Status415(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
27    Status429(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
28    Status500(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
29    Status503(models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse),
30    UnknownValue(serde_json::Value),
31}
32
33
34/// Returns the status of the transaction indicated by the specified transactionId.  **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 than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
35pub async fn get_transaction_status(configuration: &configuration::Configuration, transaction_id: &str) -> Result<models::vendor_direct_fulfillment_transactions_v1::GetTransactionResponse, Error<GetTransactionStatusError>> {
36    // add a prefix to parameters to efficiently prevent name collisions
37    let p_transaction_id = transaction_id;
38
39    let uri_str = format!("{}/vendor/directFulfillment/transactions/v1/transactions/{transactionId}", configuration.base_path, transactionId=crate::apis::urlencode(p_transaction_id));
40    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
41
42    if let Some(ref user_agent) = configuration.user_agent {
43        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
44    }
45
46    let req = req_builder.build()?;
47    let resp = configuration.client.execute(req).await?;
48
49    let status = resp.status();
50    let content_type = resp
51        .headers()
52        .get("content-type")
53        .and_then(|v| v.to_str().ok())
54        .unwrap_or("application/octet-stream");
55    let content_type = super::ContentType::from(content_type);
56
57    if !status.is_client_error() && !status.is_server_error() {
58        let content = resp.text().await?;
59        match content_type {
60            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
61            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetTransactionResponse`"))),
62            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::GetTransactionResponse`")))),
63        }
64    } else {
65        let content = resp.text().await?;
66        let entity: Option<GetTransactionStatusError> = serde_json::from_str(&content).ok();
67        Err(Error::ResponseError(ResponseContent { status, content, entity }))
68    }
69}
70