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::Bot;

impl Bot {
    /// Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty. Returns True on success.
    /// <https://core.telegram.org/bots/api#setmydescription>
    pub fn set_my_description(&self) -> SetMyDescriptionBuilder {
        SetMyDescriptionBuilder::new(self)
    }
}

#[derive(Serialize)]
pub struct SetMyDescriptionBuilder<'a> {
    #[serde(skip)]
    bot: &'a Bot,
    /// New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub language_code: Option<String>,
}

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

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

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

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