robespierre_http/
invites.rs1use robespierre_models::{channels::Channel, invites::RetrievedInvite, servers::Server};
2
3use super::impl_prelude::*;
4
5impl Http {
6 pub async fn fetch_invite(&self, invite: &str) -> Result<RetrievedInvite> {
7 Ok(self
8 .client
9 .get(ep!(self, "/invites/{}" invite))
10 .send()
11 .await?
12 .error_for_status()?
13 .json()
14 .await?)
15 }
16
17 pub async fn join_invite(&self, invite: &str) -> Result<JoinInviteResponse> {
18 Ok(self
19 .client_user_session_auth_type()
20 .post(ep!(self, "/invites/{}" invite))
21 .send()
22 .await?
23 .error_for_status()?
24 .json()
25 .await?)
26 }
27
28 pub async fn delete_invite(&self, invite: &str) -> Result {
29 self.client
30 .delete(ep!(self, "/invites/{}" invite))
31 .send()
32 .await?
33 .error_for_status()?;
34
35 Ok(())
36 }
37}
38
39#[derive(serde::Deserialize)]
40#[serde(tag = "type")]
41pub enum JoinInviteResponse {
42 Server(JoinServerInviteResponse),
43}
44
45#[derive(serde::Deserialize)]
46pub struct JoinServerInviteResponse {
47 pub channel: Channel,
48 pub server: Server,
49}