ferrisgram 0.2.1

An elegent rust client for the Telegram Bot API.
Documentation
// WARNING: THIS CODE IS AUTOGENERATED.
// DO NOT EDIT!!!

#![allow(clippy::too_many_arguments)]
use serde::Serialize;

use crate::error::Result;
use crate::types::BotName;
use crate::Bot;

impl Bot {
    /// Use this method to get the current bot name for the given user language. Returns BotName on success.
    /// <https://core.telegram.org/bots/api#getmyname>
    pub fn get_my_name(&self) -> GetMyNameBuilder {
        GetMyNameBuilder::new(self)
    }
}

#[derive(Serialize)]
pub struct GetMyNameBuilder<'a> {
    #[serde(skip)]
    bot: &'a Bot,
    /// A two-letter ISO 639-1 language code or an empty string
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language_code: Option<String>,
}

impl<'a> GetMyNameBuilder<'a> {
    pub fn new(bot: &'a Bot) -> Self {
        Self {
            bot,
            language_code: None,
        }
    }

    pub fn language_code(mut self, language_code: String) -> Self {
        self.language_code = Some(language_code);
        self
    }

    pub async fn send(self) -> Result<BotName> {
        let form = serde_json::to_value(&self)?;
        self.bot.get("getMyName", Some(&form)).await
    }
}