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 GetChatMenuButtonParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub chat_id: Option<i64>,
}
impl_into_future!(GetChatMenuButtonRequest<'a>);
#[derive(Clone)]
pub struct GetChatMenuButtonRequest<'a> {
api: &'a API,
params: GetChatMenuButtonParams,
}
impl<'a> RequestT for GetChatMenuButtonRequest<'a> {
type ParamsType = GetChatMenuButtonParams;
type ReturnType = MenuButton;
fn get_name() -> &'static str {
"getChatMenuButton"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
false
}
}
impl<'a> GetChatMenuButtonRequest<'a> {
pub fn new(api: &'a API) -> Self {
Self {
api,
params: GetChatMenuButtonParams {
chat_id: 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
}
}
impl API {
pub fn get_chat_menu_button(&self) -> GetChatMenuButtonRequest {
GetChatMenuButtonRequest::new(self)
}
}