use std::{
future::{Future, IntoFuture},
pin::Pin,
};
use serde::Serialize;
use crate::{
api::API,
entities::{
input_sticker::InputSticker,
misc::input_file::{GetFiles, InputFile},
},
errors::ConogramError,
impl_into_future_multipart,
request::RequestT,
};
#[derive(Debug, Clone, Serialize)]
pub struct AddStickerToSetParams {
pub user_id: i64,
pub name: String,
pub sticker: InputSticker,
}
impl GetFiles for AddStickerToSetParams {
fn get_files(&self) -> Vec<&InputFile> {
let mut vec = Vec::with_capacity(1);
vec.extend(self.sticker.get_files());
vec
}
}
impl_into_future_multipart!(AddStickerToSetRequest<'a>);
#[derive(Clone)]
pub struct AddStickerToSetRequest<'a> {
api: &'a API,
params: AddStickerToSetParams,
}
impl<'a> RequestT for AddStickerToSetRequest<'a> {
type ParamsType = AddStickerToSetParams;
type ReturnType = bool;
fn get_name() -> &'static str {
"addStickerToSet"
}
fn get_api_ref(&self) -> &API {
self.api
}
fn get_params_ref(&self) -> &Self::ParamsType {
&self.params
}
fn is_multipart() -> bool {
true
}
}
impl<'a> AddStickerToSetRequest<'a> {
pub fn new(
api: &'a API,
user_id: impl Into<i64>,
name: impl Into<String>,
sticker: impl Into<InputSticker>,
) -> Self {
Self {
api,
params: AddStickerToSetParams {
user_id: user_id.into(),
name: name.into(),
sticker: sticker.into(),
},
}
}
#[must_use]
pub fn user_id(mut self, user_id: impl Into<i64>) -> Self {
self.params.user_id = user_id.into();
self
}
#[must_use]
pub fn name(mut self, name: impl Into<String>) -> Self {
self.params.name = name.into();
self
}
#[must_use]
pub fn sticker(mut self, sticker: impl Into<InputSticker>) -> Self {
self.params.sticker = sticker.into();
self
}
}
impl API {
pub fn add_sticker_to_set(
&self,
user_id: impl Into<i64>,
name: impl Into<String>,
sticker: impl Into<InputSticker>,
) -> AddStickerToSetRequest {
AddStickerToSetRequest::new(self, user_id, name, sticker)
}
}