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 EditForumTopicParams {
pub chat_id: ChatId,
pub message_thread_id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_custom_emoji_id: Option<String>,
}
impl_into_future!(EditForumTopicRequest<'a>);
#[derive(Clone)]
pub struct EditForumTopicRequest<'a> {
api: &'a API,
params: EditForumTopicParams,
}
impl<'a> RequestT for EditForumTopicRequest<'a> {
type ParamsType = EditForumTopicParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"editForumTopic"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> EditForumTopicRequest<'a> {
pub fn new(
api: &'a API,
chat_id: impl Into<ChatId>,
message_thread_id: impl Into<i64>,
) -> Self {
Self {
api,
params: EditForumTopicParams {
chat_id: chat_id.into(),
message_thread_id: message_thread_id.into(),
name: Option::default(),
icon_custom_emoji_id: Option::default(),
},
}
}
#[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
}
#[must_use]
pub fn name(mut self, name: impl Into<String>) -> Self {
self.params.name = Some(name.into());
self
}
#[must_use]
pub fn icon_custom_emoji_id(mut self, icon_custom_emoji_id: impl Into<String>) -> Self {
self.params.icon_custom_emoji_id = Some(icon_custom_emoji_id.into());
self
}
}
impl API {
pub fn edit_forum_topic(
&self,
chat_id: impl Into<ChatId>,
message_thread_id: impl Into<i64>,
) -> EditForumTopicRequest {
EditForumTopicRequest::new(self, chat_id, message_thread_id)
}
}