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

impl Bot {
    /// Use this method to replace an existing sticker in a sticker set with a new one. The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. Returns True on success.
    /// <https://core.telegram.org/bots/api#replacestickerinset>
    pub fn replace_sticker_in_set(
        &self,
        user_id: i64,
        name: String,
        old_sticker: String,
        sticker: InputSticker,
    ) -> ReplaceStickerInSetBuilder {
        ReplaceStickerInSetBuilder::new(self, user_id, name, old_sticker, sticker)
    }
}

#[derive(Serialize)]
pub struct ReplaceStickerInSetBuilder<'a> {
    #[serde(skip)]
    bot: &'a Bot,
    /// User identifier of the sticker set owner
    pub user_id: i64,
    /// Sticker set name
    pub name: String,
    /// File identifier of the replaced sticker
    pub old_sticker: String,
    /// A JSON-serialized object with information about the added sticker. If exactly the same sticker had already been added to the set, then the set remains unchanged.
    pub sticker: InputSticker,
}

impl<'a> ReplaceStickerInSetBuilder<'a> {
    pub fn new(
        bot: &'a Bot,
        user_id: i64,
        name: String,
        old_sticker: String,
        sticker: InputSticker,
    ) -> Self {
        Self {
            bot,
            user_id,
            name,
            old_sticker,
            sticker,
        }
    }

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

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

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

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

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