#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::MenuButton;
use crate::Bot;
impl Bot {
pub fn set_chat_menu_button(&self) -> SetChatMenuButtonBuilder {
SetChatMenuButtonBuilder::new(self)
}
}
#[derive(Serialize)]
pub struct SetChatMenuButtonBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
#[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<'a> SetChatMenuButtonBuilder<'a> {
pub fn new(bot: &'a Bot) -> Self {
Self {
bot,
chat_id: None,
menu_button: None,
}
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = Some(chat_id);
self
}
pub fn menu_button(mut self, menu_button: MenuButton) -> Self {
self.menu_button = Some(menu_button);
self
}
pub async fn send(self) -> Result<bool> {
let form = serde_json::to_value(&self)?;
self.bot.get("setChatMenuButton", Some(&form)).await
}
}