ferrisgram/methods/
get_me.rs

1// WARNING: THIS CODE IS AUTOGENERATED.
2// DO NOT EDIT!!!
3
4#![allow(clippy::too_many_arguments)]
5use serde::Serialize;
6
7use crate::error::Result;
8use crate::types::User;
9use crate::Bot;
10
11impl Bot {
12    /// A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
13    /// <https://core.telegram.org/bots/api#getme>
14    pub fn get_me(&self) -> GetMeBuilder {
15        GetMeBuilder::new(self)
16    }
17}
18
19#[derive(Serialize)]
20pub struct GetMeBuilder<'a> {
21    #[serde(skip)]
22    bot: &'a Bot,
23}
24
25impl<'a> GetMeBuilder<'a> {
26    pub fn new(bot: &'a Bot) -> Self {
27        Self { bot }
28    }
29
30    pub async fn send(self) -> Result<User> {
31        let form = serde_json::to_value(&self)?;
32        self.bot.get("getMe", Some(&form)).await
33    }
34}