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 EditGeneralForumTopicParams {
pub chat_id: ChatId,
pub name: String,
}
impl_into_future!(EditGeneralForumTopicRequest<'a>);
#[derive(Clone)]
pub struct EditGeneralForumTopicRequest<'a> {
api: &'a API,
params: EditGeneralForumTopicParams,
}
impl<'a> RequestT for EditGeneralForumTopicRequest<'a> {
type ParamsType = EditGeneralForumTopicParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"editGeneralForumTopic"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> EditGeneralForumTopicRequest<'a> {
pub fn new(api: &'a API, chat_id: impl Into<ChatId>, name: impl Into<String>) -> Self {
Self {
api,
params: EditGeneralForumTopicParams {
chat_id: chat_id.into(),
name: name.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 name(mut self, name: impl Into<String>) -> Self {
self.params.name = name.into();
self
}
}
impl API {
pub fn edit_general_forum_topic(
&self,
chat_id: impl Into<ChatId>,
name: impl Into<String>,
) -> EditGeneralForumTopicRequest {
EditGeneralForumTopicRequest::new(self, chat_id, name)
}
}