use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{
api::API, entities::menu_button::MenuButton, errors::ConogramError, impl_into_future,
request::RequestT,
};
#[derive(Debug, Clone, Serialize)]
pub struct SetChatMenuButtonParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub chat_id: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub menu_button: Option<MenuButton>,
}
impl_into_future!(SetChatMenuButtonRequest<'a>);
#[derive(Clone)]
pub struct SetChatMenuButtonRequest<'a> {
api: &'a API,
params: SetChatMenuButtonParams,
}
impl<'a> RequestT for SetChatMenuButtonRequest<'a> {
type ParamsType = SetChatMenuButtonParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"setChatMenuButton"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> SetChatMenuButtonRequest<'a> {
pub fn new(api: &'a API) -> Self {
Self {
api,
params: SetChatMenuButtonParams {
chat_id: Option::default(),
menu_button: Option::default(),
},
}
}
#[must_use]
pub fn chat_id(mut self, chat_id: impl Into<i64>) -> Self {
self.params.chat_id = Some(chat_id.into());
self
}
#[must_use]
pub fn menu_button(mut self, menu_button: impl Into<MenuButton>) -> Self {
self.params.menu_button = Some(menu_button.into());
self
}
}
impl API {
pub fn set_chat_menu_button(&self) -> SetChatMenuButtonRequest {
SetChatMenuButtonRequest::new(self)
}
}