rive_http/customisation/
emojis.rs

1use rive_models::{data::CreateEmojiData, emoji::Emoji};
2
3use crate::prelude::*;
4
5impl Client {
6    /// Fetch an emoji by its ID.
7    pub async fn fetch_emoji(&self, id: impl Into<String>) -> Result<Emoji> {
8        Ok(self
9            .client
10            .get(ep!(self, "/custom/emoji/{}", id.into()))
11            .auth(&self.authentication)
12            .send()
13            .await?
14            .process_error()
15            .await?
16            .json()
17            .await?)
18    }
19
20    /// Create an emoji by its Autumn upload id.
21    pub async fn create_new_emoji(
22        &self,
23        id: impl Into<String>,
24        data: CreateEmojiData,
25    ) -> Result<Emoji> {
26        Ok(self
27            .client
28            .put(ep!(self, "/custom/emoji/{}", id.into()))
29            .json(&data)
30            .auth(&self.authentication)
31            .send()
32            .await?
33            .process_error()
34            .await?
35            .json()
36            .await?)
37    }
38
39    /// Delete an emoji by its id
40    pub async fn delete_emoji(&self, id: impl Into<String>) -> Result<()> {
41        self.client
42            .delete(ep!(self, "/custom/emoji/{}", id.into()))
43            .auth(&self.authentication)
44            .send()
45            .await?
46            .process_error()
47            .await?;
48        Ok(())
49    }
50}