conogram/methods/
add_sticker_to_set.rs

1use std::{
2    future::{Future, IntoFuture},
3    pin::Pin,
4};
5
6use serde::Serialize;
7
8use crate::{
9    api::API,
10    entities::{
11        input_sticker::InputSticker,
12        misc::input_file::{GetFiles, InputFile},
13    },
14    errors::ConogramError,
15    impl_into_future_multipart,
16    request::RequestT,
17};
18
19#[derive(Debug, Clone, Serialize)]
20pub struct AddStickerToSetParams {
21    pub user_id: i64,
22    pub name: String,
23    pub sticker: InputSticker,
24}
25
26impl GetFiles for AddStickerToSetParams {
27    fn get_files(&self) -> Vec<&InputFile> {
28        let mut vec = Vec::with_capacity(1);
29        vec.extend(self.sticker.get_files());
30        vec
31    }
32}
33impl_into_future_multipart!(AddStickerToSetRequest<'a>);
34
35///Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns *True* on success.
36#[derive(Clone)]
37pub struct AddStickerToSetRequest<'a> {
38    api: &'a API,
39    params: AddStickerToSetParams,
40}
41
42impl<'a> RequestT for AddStickerToSetRequest<'a> {
43    type ParamsType = AddStickerToSetParams;
44    type ReturnType = bool;
45    fn get_name() -> &'static str {
46        "addStickerToSet"
47    }
48    fn get_api_ref(&self) -> &API {
49        self.api
50    }
51    fn get_params_ref(&self) -> &Self::ParamsType {
52        &self.params
53    }
54    fn is_multipart() -> bool {
55        true
56    }
57}
58impl<'a> AddStickerToSetRequest<'a> {
59    pub fn new(
60        api: &'a API,
61        user_id: impl Into<i64>,
62        name: impl Into<String>,
63        sticker: impl Into<InputSticker>,
64    ) -> Self {
65        Self {
66            api,
67            params: AddStickerToSetParams {
68                user_id: user_id.into(),
69                name: name.into(),
70                sticker: sticker.into(),
71            },
72        }
73    }
74
75    ///User identifier of sticker set owner
76    #[must_use]
77    pub fn user_id(mut self, user_id: impl Into<i64>) -> Self {
78        self.params.user_id = user_id.into();
79        self
80    }
81
82    ///Sticker set name
83    #[must_use]
84    pub fn name(mut self, name: impl Into<String>) -> Self {
85        self.params.name = name.into();
86        self
87    }
88
89    ///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 isn't changed.
90    #[must_use]
91    pub fn sticker(mut self, sticker: impl Into<InputSticker>) -> Self {
92        self.params.sticker = sticker.into();
93        self
94    }
95}
96
97impl API {
98    ///Use this method to add a new sticker to a set created by the bot. Emoji sticker sets can have up to 200 stickers. Other sticker sets can have up to 120 stickers. Returns *True* on success.
99    pub fn add_sticker_to_set(
100        &self,
101        user_id: impl Into<i64>,
102        name: impl Into<String>,
103        sticker: impl Into<InputSticker>,
104    ) -> AddStickerToSetRequest {
105        AddStickerToSetRequest::new(self, user_id, name, sticker)
106    }
107}
108
109// Divider: all content below this line will be preserved after code regen