use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{
api::API, entities::misc::chat_id::ChatId, errors::ConogramError, impl_into_future,
request::RequestT,
};
#[derive(Debug, Clone, Serialize)]
pub struct DeleteForumTopicParams {
pub chat_id: ChatId,
pub message_thread_id: i64,
}
impl_into_future!(DeleteForumTopicRequest<'a>);
#[derive(Clone)]
pub struct DeleteForumTopicRequest<'a> {
api: &'a API,
params: DeleteForumTopicParams,
}
impl<'a> RequestT for DeleteForumTopicRequest<'a> {
type ParamsType = DeleteForumTopicParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"deleteForumTopic"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> DeleteForumTopicRequest<'a> {
pub fn new(
api: &'a API,
chat_id: impl Into<ChatId>,
message_thread_id: impl Into<i64>,
) -> Self {
Self {
api,
params: DeleteForumTopicParams {
chat_id: chat_id.into(),
message_thread_id: message_thread_id.into(),
},
}
}
#[must_use]
pub fn chat_id(mut self, chat_id: impl Into<ChatId>) -> Self {
self.params.chat_id = chat_id.into();
self
}
#[must_use]
pub fn message_thread_id(mut self, message_thread_id: impl Into<i64>) -> Self {
self.params.message_thread_id = message_thread_id.into();
self
}
}
impl API {
pub fn delete_forum_topic(
&self,
chat_id: impl Into<ChatId>,
message_thread_id: impl Into<i64>,
) -> DeleteForumTopicRequest {
DeleteForumTopicRequest::new(self, chat_id, message_thread_id)
}
}