amazon_spapi/apis/
sellers_v1.rs

1/*
2 * The Selling Partner API for Sellers
3 *
4 * The [Selling Partner API for Sellers](https://developer-docs.amazon.com/sp-api/docs/sellers-api-v1-reference) (Sellers API) provides essential information about seller accounts, such as:  - The marketplaces a seller can list in - The default language and currency of a marketplace - Whether the seller has suspended listings  Refer to the [Sellers API reference](https://developer-docs.amazon.com/sp-api/docs/sellers-api-v1-reference) for details about this API's operations, data types, and schemas.
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_account`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetAccountError {
22    Status400(models::sellers::GetAccountResponse),
23    Status403(models::sellers::GetAccountResponse),
24    Status404(models::sellers::GetAccountResponse),
25    Status413(models::sellers::GetAccountResponse),
26    Status415(models::sellers::GetAccountResponse),
27    Status429(models::sellers::GetAccountResponse),
28    Status500(models::sellers::GetAccountResponse),
29    Status503(models::sellers::GetAccountResponse),
30    UnknownValue(serde_json::Value),
31}
32
33/// struct for typed errors of method [`get_marketplace_participations`]
34#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum GetMarketplaceParticipationsError {
37    Status400(models::sellers::GetMarketplaceParticipationsResponse),
38    Status403(models::sellers::GetMarketplaceParticipationsResponse),
39    Status404(models::sellers::GetMarketplaceParticipationsResponse),
40    Status413(models::sellers::GetMarketplaceParticipationsResponse),
41    Status415(models::sellers::GetMarketplaceParticipationsResponse),
42    Status429(models::sellers::GetMarketplaceParticipationsResponse),
43    Status500(models::sellers::GetMarketplaceParticipationsResponse),
44    Status503(models::sellers::GetMarketplaceParticipationsResponse),
45    UnknownValue(serde_json::Value),
46}
47
48
49/// Returns information about a seller account and its marketplaces.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were 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 Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
50pub async fn get_account(configuration: &configuration::Configuration, ) -> Result<models::sellers::GetAccountResponse, Error<GetAccountError>> {
51
52    let uri_str = format!("{}/sellers/v1/account", configuration.base_path);
53    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
54
55    if let Some(ref user_agent) = configuration.user_agent {
56        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
57    }
58
59    let req = req_builder.build()?;
60    let resp = configuration.client.execute(req).await?;
61
62    let status = resp.status();
63    let content_type = resp
64        .headers()
65        .get("content-type")
66        .and_then(|v| v.to_str().ok())
67        .unwrap_or("application/octet-stream");
68    let content_type = super::ContentType::from(content_type);
69
70    if !status.is_client_error() && !status.is_server_error() {
71        let content = resp.text().await?;
72        match content_type {
73            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
74            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::sellers::GetAccountResponse`"))),
75            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::sellers::GetAccountResponse`")))),
76        }
77    } else {
78        let content = resp.text().await?;
79        let entity: Option<GetAccountError> = serde_json::from_str(&content).ok();
80        Err(Error::ResponseError(ResponseContent { status, content, entity }))
81    }
82}
83
84/// Returns a list of marketplaces where the seller can list items and information about the seller's participation in those marketplaces.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 0.016 | 15 |  The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were 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 Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api).
85pub async fn get_marketplace_participations(configuration: &configuration::Configuration, ) -> Result<models::sellers::GetMarketplaceParticipationsResponse, Error<GetMarketplaceParticipationsError>> {
86
87    let uri_str = format!("{}/sellers/v1/marketplaceParticipations", configuration.base_path);
88    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
89
90    if let Some(ref user_agent) = configuration.user_agent {
91        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
92    }
93
94    let req = req_builder.build()?;
95    let resp = configuration.client.execute(req).await?;
96
97    let status = resp.status();
98    let content_type = resp
99        .headers()
100        .get("content-type")
101        .and_then(|v| v.to_str().ok())
102        .unwrap_or("application/octet-stream");
103    let content_type = super::ContentType::from(content_type);
104
105    if !status.is_client_error() && !status.is_server_error() {
106        let content = resp.text().await?;
107        match content_type {
108            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
109            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::sellers::GetMarketplaceParticipationsResponse`"))),
110            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::sellers::GetMarketplaceParticipationsResponse`")))),
111        }
112    } else {
113        let content = resp.text().await?;
114        let entity: Option<GetMarketplaceParticipationsError> = serde_json::from_str(&content).ok();
115        Err(Error::ResponseError(ResponseContent { status, content, entity }))
116    }
117}
118