use crate::http::{HttpClient, Method, Request, RequestParts, encode_path};
use crate::pagination::Paginator;
use crate::types;
#[derive(Clone, Debug)]
pub struct FavoriteStickersResource {
http: HttpClient,
}
impl FavoriteStickersResource {
pub(crate) fn new(http: HttpClient) -> Self {
Self { http }
}
pub fn list(
&self,
account_id: &str,
params: types::FavoriteStickersListParams,
) -> Paginator<types::FavoriteStickerList> {
let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/stickers/favorites", encode_path(account_id)))
.query_opt("limit", params.limit.as_ref())
.retryable();
Paginator::new(self.http.clone(), parts, "cursor", params.cursor)
}
pub fn add(
&self,
account_id: &str,
params: impl Into<types::FavoriteStickersAddParams>,
) -> Request<types::FavoriteSticker> {
let params = params.into();
let parts = RequestParts::new(Method::Post, format!("/v1/accounts/{}/stickers/favorites", encode_path(account_id)))
.body(¶ms)
.keyed();
self.http.request(parts)
}
pub fn remove(&self, account_id: &str, sticker_id: &str) -> Request<()> {
let parts = RequestParts::new(Method::Delete, format!("/v1/accounts/{}/stickers/favorites/{}", encode_path(account_id), encode_path(sticker_id)))
.retryable()
.no_content();
self.http.request(parts)
}
pub fn get_media(
&self,
account_id: &str,
sticker_id: &str,
params: types::FavoriteStickersGetMediaParams,
) -> Request<types::FavoriteStickerMediaFile> {
let parts = RequestParts::new(Method::Get, format!("/v1/accounts/{}/stickers/favorites/{}/media", encode_path(account_id), encode_path(sticker_id)))
.query_opt("redirect", params.redirect.as_ref())
.retryable();
self.http.request(parts)
}
}