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