1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::prelude::*;
use rive_models::invite::{Invite, InviteJoin};

impl Client {
    /// Fetch an invite by its ID.
    pub async fn fetch_invite(&self, id: impl Into<String>) -> Result<Invite> {
        Ok(self
            .client
            .get(ep!(self, "/invites/{}", id.into()))
            .auth(&self.authentication)
            .send()
            .await?
            .process_error()
            .await?
            .json()
            .await?)
    }

    /// Join an invite by its ID.
    pub async fn join_invite(&self, id: impl Into<String>) -> Result<InviteJoin> {
        Ok(self
            .client
            .post(ep!(self, "/invites/{}", id.into()))
            .auth(&self.authentication)
            .send()
            .await?
            .process_error()
            .await?
            .json()
            .await?)
    }

    /// Delete an invite by its ID.
    pub async fn delete_invite(&self, id: impl Into<String>) -> Result<()> {
        self.client
            .delete(ep!(self, "/invites/{}", id.into()))
            .auth(&self.authentication)
            .send()
            .await?
            .process_error()
            .await?;
        Ok(())
    }
}