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::input_file::InputFile;
use crate::Bot;
use std::collections::HashMap;

impl Bot {
    /// Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set. Returns True on success.
    /// <https://core.telegram.org/bots/api#setstickersetthumbnail>
    pub fn set_sticker_set_thumbnail<F: InputFile>(
        &self,
        name: String,
        user_id: i64,
        format: String,
    ) -> SetStickerSetThumbnailBuilder<F> {
        SetStickerSetThumbnailBuilder::new(self, name, user_id, format)
    }
}

#[derive(Serialize)]
pub struct SetStickerSetThumbnailBuilder<'a, F: InputFile> {
    #[serde(skip)]
    bot: &'a Bot,
    #[serde(skip)]
    data: HashMap<&'a str, F>,
    /// Sticker set name
    pub name: String,
    /// User identifier of the sticker set owner
    pub user_id: i64,
    /// Format of the thumbnail, must be one of "static" for a .WEBP or .PNG image, "animated" for a .TGS animation, or "video" for a WEBM video
    pub format: String,
}

impl<'a, F: InputFile> SetStickerSetThumbnailBuilder<'a, F> {
    pub fn new(bot: &'a Bot, name: String, user_id: i64, format: String) -> Self {
        let data = HashMap::new();
        Self {
            bot,
            data,
            name,
            user_id,
            format,
        }
    }

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

    pub fn user_id(mut self, user_id: i64) -> Self {
        self.user_id = user_id;
        self
    }

    pub fn thumbnail(mut self, thumbnail: F) -> Self {
        self.data.insert("thumbnail", thumbnail);
        self
    }

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

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