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