use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{
api::API, errors::ConogramError, impl_into_future, request::RequestT,
utils::deserialize_utils::is_false,
};
#[derive(Debug, Clone, Serialize)]
pub struct DeleteWebhookParams {
#[serde(default, skip_serializing_if = "is_false")]
pub drop_pending_updates: bool,
}
impl_into_future!(DeleteWebhookRequest<'a>);
#[derive(Clone)]
pub struct DeleteWebhookRequest<'a> {
api: &'a API,
params: DeleteWebhookParams,
}
impl<'a> RequestT for DeleteWebhookRequest<'a> {
type ParamsType = DeleteWebhookParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"deleteWebhook"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> DeleteWebhookRequest<'a> {
pub fn new(api: &'a API) -> Self {
Self {
api,
params: DeleteWebhookParams {
drop_pending_updates: bool::default(),
},
}
}
#[must_use]
pub fn drop_pending_updates(mut self, drop_pending_updates: impl Into<bool>) -> Self {
self.params.drop_pending_updates = drop_pending_updates.into();
self
}
}
impl API {
pub fn delete_webhook(&self) -> DeleteWebhookRequest {
DeleteWebhookRequest::new(self)
}
}