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::ChatAdministratorRights;
use crate::Bot;

impl Bot {
    /// Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
    /// <https://core.telegram.org/bots/api#getmydefaultadministratorrights>
    pub fn get_my_default_administrator_rights(&self) -> GetMyDefaultAdministratorRightsBuilder {
        GetMyDefaultAdministratorRightsBuilder::new(self)
    }
}

#[derive(Serialize)]
pub struct GetMyDefaultAdministratorRightsBuilder<'a> {
    #[serde(skip)]
    bot: &'a Bot,
    /// Pass True to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub for_channels: Option<bool>,
}

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

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

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