use super::base::{Request, TelegramMethod};
use crate::{
client::Bot,
types::{InlineKeyboardMarkup, Message, ReplyParameters},
};
use serde::Serialize;
use serde_with::skip_serializing_none;
#[skip_serializing_none]
#[derive(Debug, Clone, Hash, PartialEq, Eq, Serialize)]
pub struct SendGame {
pub chat_id: i64,
pub message_thread_id: Option<i64>,
pub game_short_name: String,
pub disable_notification: Option<bool>,
pub protect_content: Option<bool>,
pub reply_parameters: Option<ReplyParameters>,
pub reply_markup: Option<InlineKeyboardMarkup>,
}
impl SendGame {
#[must_use]
pub fn new(chat_id: i64, game_short_name: impl Into<String>) -> Self {
Self {
chat_id,
message_thread_id: None,
game_short_name: game_short_name.into(),
disable_notification: None,
protect_content: None,
reply_parameters: None,
reply_markup: None,
}
}
#[must_use]
pub fn chat_id(self, val: i64) -> Self {
Self {
chat_id: val,
..self
}
}
#[must_use]
pub fn message_thread_id(self, val: i64) -> Self {
Self {
message_thread_id: Some(val),
..self
}
}
#[must_use]
pub fn game_short_name(self, val: impl Into<String>) -> Self {
Self {
game_short_name: val.into(),
..self
}
}
#[must_use]
pub fn disable_notification(self, val: bool) -> Self {
Self {
disable_notification: Some(val),
..self
}
}
#[must_use]
pub fn protect_content(self, val: bool) -> Self {
Self {
protect_content: Some(val),
..self
}
}
#[must_use]
pub fn reply_parameters(self, val: ReplyParameters) -> Self {
Self {
reply_parameters: Some(val),
..self
}
}
#[must_use]
pub fn reply_markup(self, val: impl Into<InlineKeyboardMarkup>) -> Self {
Self {
reply_markup: Some(val.into()),
..self
}
}
}
impl SendGame {
#[must_use]
pub fn message_thread_id_option(self, val: Option<i64>) -> Self {
Self {
message_thread_id: val,
..self
}
}
#[must_use]
pub fn disable_notification_option(self, val: Option<bool>) -> Self {
Self {
disable_notification: val,
..self
}
}
#[must_use]
pub fn protect_content_option(self, val: Option<bool>) -> Self {
Self {
protect_content: val,
..self
}
}
#[must_use]
pub fn reply_parameters_option(self, val: Option<ReplyParameters>) -> Self {
Self {
reply_parameters: val,
..self
}
}
#[must_use]
pub fn reply_markup_option(self, val: Option<impl Into<InlineKeyboardMarkup>>) -> Self {
Self {
reply_markup: val.map(Into::into),
..self
}
}
}
impl TelegramMethod for SendGame {
type Method = Self;
type Return = Message;
fn build_request<Client>(&self, _bot: &Bot<Client>) -> Request<Self::Method> {
Request::new("sendGame", self, None)
}
}
impl AsRef<SendGame> for SendGame {
fn as_ref(&self) -> &Self {
self
}
}