rive_http/channels/
channel_information.rs

1use crate::prelude::*;
2use rive_models::{channel::Channel, data::EditChannelData};
3
4impl Client {
5    /// Fetch channel by its ID.
6    pub async fn fetch_channel(&self, id: impl Into<String>) -> Result<Channel> {
7        Ok(self
8            .client
9            .get(ep!(self, "/channels/{}", id.into()))
10            .auth(&self.authentication)
11            .send()
12            .await?
13            .process_error()
14            .await?
15            .json()
16            .await?)
17    }
18
19    /// Deletes a server channel, leaves a group or closes a group.
20    pub async fn close_channel(&self, id: impl Into<String>) -> Result<()> {
21        self.client
22            .delete(ep!(self, "/channels/{}", id.into()))
23            .auth(&self.authentication)
24            .send()
25            .await?
26            .process_error()
27            .await?;
28        Ok(())
29    }
30
31    /// Edit a channel object by its id.
32    pub async fn edit_channel(
33        &self,
34        id: impl Into<String>,
35        data: EditChannelData,
36    ) -> Result<Channel> {
37        Ok(self
38            .client
39            .patch(ep!(self, "/channels/{}", id.into()))
40            .auth(&self.authentication)
41            .json(&data)
42            .send()
43            .await?
44            .process_error()
45            .await?
46            .json()
47            .await?)
48    }
49}