twilight_http/request/application/monetization/
delete_test_entitlement.rs1use std::future::IntoFuture;
2
3use twilight_model::id::{
4 Id,
5 marker::{ApplicationMarker, EntitlementMarker},
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::EmptyBody},
17};
18
19pub struct DeleteTestEntitlement<'a> {
20 application_id: Id<ApplicationMarker>,
21 entitlement_id: Id<EntitlementMarker>,
22 http: &'a Client,
23}
24
25impl<'a> DeleteTestEntitlement<'a> {
26 pub(crate) const fn new(
27 http: &'a Client,
28 application_id: Id<ApplicationMarker>,
29 entitlement_id: Id<EntitlementMarker>,
30 ) -> Self {
31 Self {
32 application_id,
33 entitlement_id,
34 http,
35 }
36 }
37}
38
39#[cfg(not(target_os = "wasi"))]
40impl IntoFuture for DeleteTestEntitlement<'_> {
41 type Output = Result<Response<EmptyBody>, Error>;
42
43 type IntoFuture = ResponseFuture<EmptyBody>;
44
45 fn into_future(self) -> Self::IntoFuture {
46 let http = self.http;
47
48 match self.try_into_request() {
49 Ok(request) => http.request(request),
50 Err(source) => ResponseFuture::error(source),
51 }
52 }
53}
54
55impl TryIntoRequest for DeleteTestEntitlement<'_> {
56 fn try_into_request(self) -> Result<Request, Error> {
57 Request::builder(&Route::DeleteTestEntitlement {
58 application_id: self.application_id.get(),
59 entitlement_id: self.entitlement_id.get(),
60 })
61 .build()
62 }
63}