amazon_spapi/apis/
sellers_v1.rs1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[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#[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
49pub 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
84pub 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