some_random_api/endpoints/
premium.rs1use crate::{RankCard, Requester, WelcomeImage};
2use anyhow::Result;
3use serde_json::to_string;
4
5pub struct PremiumEndpoint(pub(crate) Requester);
21
22impl PremiumEndpoint {
23 pub async fn among_us<T: ToString, U: ToString, V: ToString>(
25 &self,
26 username: T,
27 avatar_url: U,
28 text: Option<V>,
29 ) -> Result<Vec<u8>> {
30 self.0
31 .request_image(
32 "premium/amongus",
33 &[
34 ("username", username.to_string()),
35 ("avatar", avatar_url.to_string()),
36 ("custom", text.map_or("".into(), |text| text.to_string())),
37 ],
38 )
39 .await
40 }
41
42 pub async fn petpet<T: ToString>(&self, avatar_url: T) -> Result<Vec<u8>> {
44 self.0
45 .request_image("premium/petpet", &[("avatar", avatar_url.to_string())])
46 .await
47 }
48
49 pub async fn rank_card(&self, rank_card: RankCard) -> Result<Vec<u8>> {
51 self.0
52 .request_image(
53 format!("premium/rankcard/{}", to_string(&rank_card.template)?),
54 &rank_card,
55 )
56 .await
57 }
58
59 pub async fn welcome(&self, welcome_image: WelcomeImage) -> Result<Vec<u8>> {
61 self.0
62 .request_image(
63 format!("premium/welcome/{}", to_string(&welcome_image.template)?),
64 &welcome_image,
65 )
66 .await
67 }
68}