twilight_http/request/application/monetization/
get_skus.rs

1use std::future::IntoFuture;
2
3use twilight_model::{
4    application::monetization::Sku,
5    id::{marker::ApplicationMarker, Id},
6};
7
8use crate::{
9    request::{Request, TryIntoRequest},
10    response::{marker::ListBody, ResponseFuture},
11    routing::Route,
12    Client, Error, Response,
13};
14
15pub struct GetSKUs<'a> {
16    application_id: Id<ApplicationMarker>,
17    http: &'a Client,
18}
19
20impl<'a> GetSKUs<'a> {
21    pub(crate) const fn new(http: &'a Client, application_id: Id<ApplicationMarker>) -> Self {
22        Self {
23            application_id,
24            http,
25        }
26    }
27}
28
29impl IntoFuture for GetSKUs<'_> {
30    type Output = Result<Response<ListBody<Sku>>, Error>;
31    type IntoFuture = ResponseFuture<ListBody<Sku>>;
32
33    fn into_future(self) -> Self::IntoFuture {
34        let http = self.http;
35
36        match self.try_into_request() {
37            Ok(request) => http.request(request),
38            Err(source) => ResponseFuture::error(source),
39        }
40    }
41}
42
43impl TryIntoRequest for GetSKUs<'_> {
44    fn try_into_request(self) -> Result<Request, Error> {
45        Ok(Request::from_route(&Route::GetSKUs {
46            application_id: self.application_id.get(),
47        }))
48    }
49}