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 short description, which is shown on the bot's profile page and is sent together with the link when users share the bot. Returns True on success.
    /// <https://core.telegram.org/bots/api#setmyshortdescription>
    pub fn set_my_short_description(&self) -> SetMyShortDescriptionBuilder {
        SetMyShortDescriptionBuilder::new(self)
    }
}

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

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

    pub fn short_description(mut self, short_description: String) -> Self {
        self.short_description = Some(short_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("setMyShortDescription", Some(&form)).await
    }
}