amazon_spapi/apis/
notifications_v1.rs

1/*
2 * Selling Partner API for Notifications
3 *
4 * The Selling Partner API for Notifications lets you subscribe to notifications that are relevant to a selling partner's business. Using this API you can create a destination to receive notifications, subscribe to notifications, delete notification subscriptions, and more.  For more information, refer to the [Notifications Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/notifications-api-v1-use-case-guide).
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 [`create_destination`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateDestinationError {
22    Status400(models::notifications::CreateDestinationResponse),
23    Status403(models::notifications::CreateDestinationResponse),
24    Status404(models::notifications::CreateDestinationResponse),
25    Status409(models::notifications::CreateDestinationResponse),
26    Status413(models::notifications::CreateDestinationResponse),
27    Status415(models::notifications::CreateDestinationResponse),
28    Status429(models::notifications::CreateDestinationResponse),
29    Status500(models::notifications::CreateDestinationResponse),
30    Status503(models::notifications::CreateDestinationResponse),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`create_subscription`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum CreateSubscriptionError {
38    Status400(models::notifications::CreateSubscriptionResponse),
39    Status403(models::notifications::CreateSubscriptionResponse),
40    Status404(models::notifications::CreateSubscriptionResponse),
41    Status409(models::notifications::CreateSubscriptionResponse),
42    Status413(models::notifications::CreateSubscriptionResponse),
43    Status415(models::notifications::CreateSubscriptionResponse),
44    Status429(models::notifications::CreateSubscriptionResponse),
45    Status500(models::notifications::CreateSubscriptionResponse),
46    Status503(models::notifications::CreateSubscriptionResponse),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`delete_destination`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum DeleteDestinationError {
54    Status400(models::notifications::DeleteDestinationResponse),
55    Status403(models::notifications::DeleteDestinationResponse),
56    Status404(models::notifications::DeleteDestinationResponse),
57    Status409(models::notifications::DeleteDestinationResponse),
58    Status413(models::notifications::DeleteDestinationResponse),
59    Status415(models::notifications::DeleteDestinationResponse),
60    Status429(models::notifications::DeleteDestinationResponse),
61    Status500(models::notifications::DeleteDestinationResponse),
62    Status503(models::notifications::DeleteDestinationResponse),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`delete_subscription_by_id`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum DeleteSubscriptionByIdError {
70    Status400(models::notifications::DeleteSubscriptionByIdResponse),
71    Status403(models::notifications::DeleteSubscriptionByIdResponse),
72    Status404(models::notifications::DeleteSubscriptionByIdResponse),
73    Status409(models::notifications::DeleteSubscriptionByIdResponse),
74    Status413(models::notifications::DeleteSubscriptionByIdResponse),
75    Status415(models::notifications::DeleteSubscriptionByIdResponse),
76    Status429(models::notifications::DeleteSubscriptionByIdResponse),
77    Status500(models::notifications::DeleteSubscriptionByIdResponse),
78    Status503(models::notifications::DeleteSubscriptionByIdResponse),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`get_destination`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum GetDestinationError {
86    Status400(models::notifications::GetDestinationResponse),
87    Status403(models::notifications::GetDestinationResponse),
88    Status404(models::notifications::GetDestinationResponse),
89    Status409(models::notifications::GetDestinationResponse),
90    Status413(models::notifications::GetDestinationResponse),
91    Status415(models::notifications::GetDestinationResponse),
92    Status429(models::notifications::GetDestinationResponse),
93    Status500(models::notifications::GetDestinationResponse),
94    Status503(models::notifications::GetDestinationResponse),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`get_destinations`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum GetDestinationsError {
102    Status400(models::notifications::GetDestinationsResponse),
103    Status403(models::notifications::GetDestinationsResponse),
104    Status404(models::notifications::GetDestinationsResponse),
105    Status409(models::notifications::GetDestinationsResponse),
106    Status413(models::notifications::GetDestinationsResponse),
107    Status415(models::notifications::GetDestinationsResponse),
108    Status429(models::notifications::GetDestinationsResponse),
109    Status500(models::notifications::GetDestinationsResponse),
110    Status503(models::notifications::GetDestinationsResponse),
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`get_subscription`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum GetSubscriptionError {
118    Status400(models::notifications::GetSubscriptionResponse),
119    Status403(models::notifications::GetSubscriptionResponse),
120    Status404(models::notifications::GetSubscriptionResponse),
121    Status413(models::notifications::GetSubscriptionResponse),
122    Status415(models::notifications::GetSubscriptionResponse),
123    Status429(models::notifications::GetSubscriptionResponse),
124    Status500(models::notifications::GetSubscriptionResponse),
125    Status503(models::notifications::GetSubscriptionResponse),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`get_subscription_by_id`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum GetSubscriptionByIdError {
133    Status400(models::notifications::GetSubscriptionByIdResponse),
134    Status403(models::notifications::GetSubscriptionByIdResponse),
135    Status404(models::notifications::GetSubscriptionResponse),
136    Status409(models::notifications::GetSubscriptionByIdResponse),
137    Status413(models::notifications::GetSubscriptionByIdResponse),
138    Status415(models::notifications::GetSubscriptionByIdResponse),
139    Status429(models::notifications::GetSubscriptionByIdResponse),
140    Status500(models::notifications::GetSubscriptionByIdResponse),
141    Status503(models::notifications::GetSubscriptionByIdResponse),
142    UnknownValue(serde_json::Value),
143}
144
145
146/// Creates a destination resource to receive notifications. The `createDestination` operation is grantless. For more information, refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
147pub async fn create_destination(configuration: &configuration::Configuration, body: models::notifications::CreateDestinationRequest) -> Result<models::notifications::CreateDestinationResponse, Error<CreateDestinationError>> {
148    // add a prefix to parameters to efficiently prevent name collisions
149    let p_body = body;
150
151    let uri_str = format!("{}/notifications/v1/destinations", configuration.base_path);
152    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
153
154    if let Some(ref user_agent) = configuration.user_agent {
155        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
156    }
157    req_builder = req_builder.json(&p_body);
158
159    let req = req_builder.build()?;
160    let resp = configuration.client.execute(req).await?;
161
162    let status = resp.status();
163    let content_type = resp
164        .headers()
165        .get("content-type")
166        .and_then(|v| v.to_str().ok())
167        .unwrap_or("application/octet-stream");
168    let content_type = super::ContentType::from(content_type);
169
170    if !status.is_client_error() && !status.is_server_error() {
171        let content = resp.text().await?;
172        match content_type {
173            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
174            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::CreateDestinationResponse`"))),
175            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::notifications::CreateDestinationResponse`")))),
176        }
177    } else {
178        let content = resp.text().await?;
179        let entity: Option<CreateDestinationError> = serde_json::from_str(&content).ok();
180        Err(Error::ResponseError(ResponseContent { status, content, entity }))
181    }
182}
183
184/// Creates a subscription for the specified notification type to be delivered to the specified destination. Before you can subscribe, you must first create the destination by calling the `createDestination` operation. In cases where the specified notification type supports multiple payload versions, you can utilize this API to subscribe to a different payload version if you already have an existing subscription for a different payload version.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
185pub async fn create_subscription(configuration: &configuration::Configuration, notification_type: &str, body: models::notifications::CreateSubscriptionRequest) -> Result<models::notifications::CreateSubscriptionResponse, Error<CreateSubscriptionError>> {
186    // add a prefix to parameters to efficiently prevent name collisions
187    let p_notification_type = notification_type;
188    let p_body = body;
189
190    let uri_str = format!("{}/notifications/v1/subscriptions/{notificationType}", configuration.base_path, notificationType=crate::apis::urlencode(p_notification_type));
191    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
192
193    if let Some(ref user_agent) = configuration.user_agent {
194        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
195    }
196    req_builder = req_builder.json(&p_body);
197
198    let req = req_builder.build()?;
199    let resp = configuration.client.execute(req).await?;
200
201    let status = resp.status();
202    let content_type = resp
203        .headers()
204        .get("content-type")
205        .and_then(|v| v.to_str().ok())
206        .unwrap_or("application/octet-stream");
207    let content_type = super::ContentType::from(content_type);
208
209    if !status.is_client_error() && !status.is_server_error() {
210        let content = resp.text().await?;
211        match content_type {
212            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
213            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::CreateSubscriptionResponse`"))),
214            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::notifications::CreateSubscriptionResponse`")))),
215        }
216    } else {
217        let content = resp.text().await?;
218        let entity: Option<CreateSubscriptionError> = serde_json::from_str(&content).ok();
219        Err(Error::ResponseError(ResponseContent { status, content, entity }))
220    }
221}
222
223/// Deletes the destination that you specify. The `deleteDestination` operation is grantless. For more information, refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
224pub async fn delete_destination(configuration: &configuration::Configuration, destination_id: &str) -> Result<models::notifications::DeleteDestinationResponse, Error<DeleteDestinationError>> {
225    // add a prefix to parameters to efficiently prevent name collisions
226    let p_destination_id = destination_id;
227
228    let uri_str = format!("{}/notifications/v1/destinations/{destinationId}", configuration.base_path, destinationId=crate::apis::urlencode(p_destination_id));
229    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
230
231    if let Some(ref user_agent) = configuration.user_agent {
232        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
233    }
234
235    let req = req_builder.build()?;
236    let resp = configuration.client.execute(req).await?;
237
238    let status = resp.status();
239    let content_type = resp
240        .headers()
241        .get("content-type")
242        .and_then(|v| v.to_str().ok())
243        .unwrap_or("application/octet-stream");
244    let content_type = super::ContentType::from(content_type);
245
246    if !status.is_client_error() && !status.is_server_error() {
247        let content = resp.text().await?;
248        match content_type {
249            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
250            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::DeleteDestinationResponse`"))),
251            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::notifications::DeleteDestinationResponse`")))),
252        }
253    } else {
254        let content = resp.text().await?;
255        let entity: Option<DeleteDestinationError> = serde_json::from_str(&content).ok();
256        Err(Error::ResponseError(ResponseContent { status, content, entity }))
257    }
258}
259
260/// Deletes the subscription indicated by the subscription identifier and notification type that you specify. The subscription identifier can be for any subscription associated with your application. After you successfully call this operation, notifications will stop being sent for the associated subscription. The `deleteSubscriptionById` operation is grantless. For more information, refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
261pub async fn delete_subscription_by_id(configuration: &configuration::Configuration, subscription_id: &str, notification_type: &str) -> Result<models::notifications::DeleteSubscriptionByIdResponse, Error<DeleteSubscriptionByIdError>> {
262    // add a prefix to parameters to efficiently prevent name collisions
263    let p_subscription_id = subscription_id;
264    let p_notification_type = notification_type;
265
266    let uri_str = format!("{}/notifications/v1/subscriptions/{notificationType}/{subscriptionId}", configuration.base_path, subscriptionId=crate::apis::urlencode(p_subscription_id), notificationType=crate::apis::urlencode(p_notification_type));
267    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
268
269    if let Some(ref user_agent) = configuration.user_agent {
270        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
271    }
272
273    let req = req_builder.build()?;
274    let resp = configuration.client.execute(req).await?;
275
276    let status = resp.status();
277    let content_type = resp
278        .headers()
279        .get("content-type")
280        .and_then(|v| v.to_str().ok())
281        .unwrap_or("application/octet-stream");
282    let content_type = super::ContentType::from(content_type);
283
284    if !status.is_client_error() && !status.is_server_error() {
285        let content = resp.text().await?;
286        match content_type {
287            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
288            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::DeleteSubscriptionByIdResponse`"))),
289            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::notifications::DeleteSubscriptionByIdResponse`")))),
290        }
291    } else {
292        let content = resp.text().await?;
293        let entity: Option<DeleteSubscriptionByIdError> = serde_json::from_str(&content).ok();
294        Err(Error::ResponseError(ResponseContent { status, content, entity }))
295    }
296}
297
298/// Returns information about the destination that you specify. The `getDestination` operation is grantless. For more information, refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
299pub async fn get_destination(configuration: &configuration::Configuration, destination_id: &str) -> Result<models::notifications::GetDestinationResponse, Error<GetDestinationError>> {
300    // add a prefix to parameters to efficiently prevent name collisions
301    let p_destination_id = destination_id;
302
303    let uri_str = format!("{}/notifications/v1/destinations/{destinationId}", configuration.base_path, destinationId=crate::apis::urlencode(p_destination_id));
304    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
305
306    if let Some(ref user_agent) = configuration.user_agent {
307        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308    }
309
310    let req = req_builder.build()?;
311    let resp = configuration.client.execute(req).await?;
312
313    let status = resp.status();
314    let content_type = resp
315        .headers()
316        .get("content-type")
317        .and_then(|v| v.to_str().ok())
318        .unwrap_or("application/octet-stream");
319    let content_type = super::ContentType::from(content_type);
320
321    if !status.is_client_error() && !status.is_server_error() {
322        let content = resp.text().await?;
323        match content_type {
324            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
325            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::GetDestinationResponse`"))),
326            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::notifications::GetDestinationResponse`")))),
327        }
328    } else {
329        let content = resp.text().await?;
330        let entity: Option<GetDestinationError> = serde_json::from_str(&content).ok();
331        Err(Error::ResponseError(ResponseContent { status, content, entity }))
332    }
333}
334
335/// Returns information about all destinations. The `getDestinations` operation is grantless. For more information, refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
336pub async fn get_destinations(configuration: &configuration::Configuration, ) -> Result<models::notifications::GetDestinationsResponse, Error<GetDestinationsError>> {
337
338    let uri_str = format!("{}/notifications/v1/destinations", configuration.base_path);
339    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
340
341    if let Some(ref user_agent) = configuration.user_agent {
342        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
343    }
344
345    let req = req_builder.build()?;
346    let resp = configuration.client.execute(req).await?;
347
348    let status = resp.status();
349    let content_type = resp
350        .headers()
351        .get("content-type")
352        .and_then(|v| v.to_str().ok())
353        .unwrap_or("application/octet-stream");
354    let content_type = super::ContentType::from(content_type);
355
356    if !status.is_client_error() && !status.is_server_error() {
357        let content = resp.text().await?;
358        match content_type {
359            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
360            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::GetDestinationsResponse`"))),
361            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::notifications::GetDestinationsResponse`")))),
362        }
363    } else {
364        let content = resp.text().await?;
365        let entity: Option<GetDestinationsError> = serde_json::from_str(&content).ok();
366        Err(Error::ResponseError(ResponseContent { status, content, entity }))
367    }
368}
369
370/// Returns information about subscription of the specified notification type and payload version. `payloadVersion` is an optional parameter. When `payloadVersion` is not provided, it will return latest payload version subscription's information. You can use this API to get subscription information when you do not have a subscription identifier.  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
371pub async fn get_subscription(configuration: &configuration::Configuration, notification_type: &str, payload_version: Option<&str>) -> Result<models::notifications::GetSubscriptionResponse, Error<GetSubscriptionError>> {
372    // add a prefix to parameters to efficiently prevent name collisions
373    let p_notification_type = notification_type;
374    let p_payload_version = payload_version;
375
376    let uri_str = format!("{}/notifications/v1/subscriptions/{notificationType}", configuration.base_path, notificationType=crate::apis::urlencode(p_notification_type));
377    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
378
379    if let Some(ref param_value) = p_payload_version {
380        req_builder = req_builder.query(&[("payloadVersion", &param_value.to_string())]);
381    }
382    if let Some(ref user_agent) = configuration.user_agent {
383        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
384    }
385
386    let req = req_builder.build()?;
387    let resp = configuration.client.execute(req).await?;
388
389    let status = resp.status();
390    let content_type = resp
391        .headers()
392        .get("content-type")
393        .and_then(|v| v.to_str().ok())
394        .unwrap_or("application/octet-stream");
395    let content_type = super::ContentType::from(content_type);
396
397    if !status.is_client_error() && !status.is_server_error() {
398        let content = resp.text().await?;
399        match content_type {
400            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
401            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::GetSubscriptionResponse`"))),
402            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::notifications::GetSubscriptionResponse`")))),
403        }
404    } else {
405        let content = resp.text().await?;
406        let entity: Option<GetSubscriptionError> = serde_json::from_str(&content).ok();
407        Err(Error::ResponseError(ResponseContent { status, content, entity }))
408    }
409}
410
411/// Returns information about a subscription for the specified notification type. The `getSubscriptionById` operation is grantless. For more information, refer to [Grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations).  **Usage Plan:**  | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 |  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 observe 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).
412pub async fn get_subscription_by_id(configuration: &configuration::Configuration, subscription_id: &str, notification_type: &str) -> Result<models::notifications::GetSubscriptionByIdResponse, Error<GetSubscriptionByIdError>> {
413    // add a prefix to parameters to efficiently prevent name collisions
414    let p_subscription_id = subscription_id;
415    let p_notification_type = notification_type;
416
417    let uri_str = format!("{}/notifications/v1/subscriptions/{notificationType}/{subscriptionId}", configuration.base_path, subscriptionId=crate::apis::urlencode(p_subscription_id), notificationType=crate::apis::urlencode(p_notification_type));
418    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
419
420    if let Some(ref user_agent) = configuration.user_agent {
421        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
422    }
423
424    let req = req_builder.build()?;
425    let resp = configuration.client.execute(req).await?;
426
427    let status = resp.status();
428    let content_type = resp
429        .headers()
430        .get("content-type")
431        .and_then(|v| v.to_str().ok())
432        .unwrap_or("application/octet-stream");
433    let content_type = super::ContentType::from(content_type);
434
435    if !status.is_client_error() && !status.is_server_error() {
436        let content = resp.text().await?;
437        match content_type {
438            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
439            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::notifications::GetSubscriptionByIdResponse`"))),
440            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::notifications::GetSubscriptionByIdResponse`")))),
441        }
442    } else {
443        let content = resp.text().await?;
444        let entity: Option<GetSubscriptionByIdError> = serde_json::from_str(&content).ok();
445        Err(Error::ResponseError(ResponseContent { status, content, entity }))
446    }
447}
448