#![allow(clippy::too_many_arguments)]
use serde::Serialize;
use crate::error::Result;
use crate::types::GameHighScore;
use crate::Bot;
impl Bot {
pub fn get_game_high_scores(&self, user_id: i64) -> GetGameHighScoresBuilder {
GetGameHighScoresBuilder::new(self, user_id)
}
}
#[derive(Serialize)]
pub struct GetGameHighScoresBuilder<'a> {
#[serde(skip)]
bot: &'a Bot,
pub user_id: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub chat_id: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub message_id: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub inline_message_id: Option<String>,
}
impl<'a> GetGameHighScoresBuilder<'a> {
pub fn new(bot: &'a Bot, user_id: i64) -> Self {
Self {
bot,
user_id,
chat_id: None,
message_id: None,
inline_message_id: None,
}
}
pub fn user_id(mut self, user_id: i64) -> Self {
self.user_id = user_id;
self
}
pub fn chat_id(mut self, chat_id: i64) -> Self {
self.chat_id = Some(chat_id);
self
}
pub fn message_id(mut self, message_id: i64) -> Self {
self.message_id = Some(message_id);
self
}
pub fn inline_message_id(mut self, inline_message_id: String) -> Self {
self.inline_message_id = Some(inline_message_id);
self
}
pub async fn send(self) -> Result<Vec<GameHighScore>> {
let form = serde_json::to_value(&self)?;
self.bot.get("getGameHighScores", Some(&form)).await
}
}