use super::base::{Request, TelegramMethod};
use crate::{client::Bot, types::MenuButton};
use serde::Serialize;
use serde_with::skip_serializing_none;
#[skip_serializing_none]
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)]
pub struct SetChatMenuButton {
pub chat_id: i64,
pub menu_button: Option<MenuButton>,
}
impl SetChatMenuButton {
#[must_use]
pub fn new(chat_id: i64) -> Self {
Self {
chat_id,
menu_button: None,
}
}
#[must_use]
pub fn chat_id(self, val: i64) -> Self {
Self {
chat_id: val,
..self
}
}
#[must_use]
pub fn menu_button(self, val: impl Into<MenuButton>) -> Self {
Self {
menu_button: Some(val.into()),
..self
}
}
}
impl SetChatMenuButton {
#[must_use]
pub fn menu_button_option(self, val: Option<impl Into<MenuButton>>) -> Self {
Self {
menu_button: val.map(Into::into),
..self
}
}
}
impl TelegramMethod for SetChatMenuButton {
type Method = Self;
type Return = bool;
fn build_request<Client>(&self, _bot: &Bot<Client>) -> Request<Self::Method> {
Request::new("setChatMenuButton", self, None)
}
}