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 move a sticker in a set created by the bot to a specific position. Returns True on success.
    /// <https://core.telegram.org/bots/api#setstickerpositioninset>
    pub fn set_sticker_position_in_set(
        &self,
        sticker: String,
        position: i64,
    ) -> SetStickerPositionInSetBuilder {
        SetStickerPositionInSetBuilder::new(self, sticker, position)
    }
}

#[derive(Serialize)]
pub struct SetStickerPositionInSetBuilder<'a> {
    #[serde(skip)]
    bot: &'a Bot,
    /// File identifier of the sticker
    pub sticker: String,
    /// New sticker position in the set, zero-based
    pub position: i64,
}

impl<'a> SetStickerPositionInSetBuilder<'a> {
    pub fn new(bot: &'a Bot, sticker: String, position: i64) -> Self {
        Self {
            bot,
            sticker,
            position,
        }
    }

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

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

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