jacquard_api/chat_bsky/group/
enable_join_link.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11use crate::chat_bsky::group::JoinLinkView;
12#[allow(unused_imports)]
13use core::marker::PhantomData;
14use jacquard_common::deps::smol_str::SmolStr;
15use jacquard_common::types::value::Data;
16use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
17use jacquard_derive::{IntoStatic, open_union};
18use serde::{Deserialize, Serialize};
19
20#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
21#[serde(
22 rename_all = "camelCase",
23 bound(deserialize = "S: Deserialize<'de> + BosStr")
24)]
25pub struct EnableJoinLink<S: BosStr = DefaultStr> {
26 pub convo_id: S,
27 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
28 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
29}
30
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
32#[serde(
33 rename_all = "camelCase",
34 bound(deserialize = "S: Deserialize<'de> + BosStr")
35)]
36pub struct EnableJoinLinkOutput<S: BosStr = DefaultStr> {
37 pub join_link: JoinLinkView<S>,
38 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
39 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
40}
41
42#[derive(
43 Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
44)]
45#[serde(tag = "error", content = "message")]
46pub enum EnableJoinLinkError {
47 #[serde(rename = "InvalidConvo")]
48 InvalidConvo(Option<SmolStr>),
49 #[serde(rename = "InsufficientRole")]
50 InsufficientRole(Option<SmolStr>),
51 #[serde(rename = "NoJoinLink")]
52 NoJoinLink(Option<SmolStr>),
53 #[serde(rename = "LinkAlreadyEnabled")]
54 LinkAlreadyEnabled(Option<SmolStr>),
55 #[serde(untagged)]
57 Other {
58 error: SmolStr,
59 message: Option<SmolStr>,
60 },
61}
62
63impl core::fmt::Display for EnableJoinLinkError {
64 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
65 match self {
66 Self::InvalidConvo(msg) => {
67 write!(f, "InvalidConvo")?;
68 if let Some(msg) = msg {
69 write!(f, ": {}", msg)?;
70 }
71 Ok(())
72 }
73 Self::InsufficientRole(msg) => {
74 write!(f, "InsufficientRole")?;
75 if let Some(msg) = msg {
76 write!(f, ": {}", msg)?;
77 }
78 Ok(())
79 }
80 Self::NoJoinLink(msg) => {
81 write!(f, "NoJoinLink")?;
82 if let Some(msg) = msg {
83 write!(f, ": {}", msg)?;
84 }
85 Ok(())
86 }
87 Self::LinkAlreadyEnabled(msg) => {
88 write!(f, "LinkAlreadyEnabled")?;
89 if let Some(msg) = msg {
90 write!(f, ": {}", msg)?;
91 }
92 Ok(())
93 }
94 Self::Other { error, message } => {
95 write!(f, "{}", error)?;
96 if let Some(msg) = message {
97 write!(f, ": {}", msg)?;
98 }
99 Ok(())
100 }
101 }
102 }
103}
104
105pub struct EnableJoinLinkResponse;
109impl jacquard_common::xrpc::XrpcResp for EnableJoinLinkResponse {
110 const NSID: &'static str = "chat.bsky.group.enableJoinLink";
111 const ENCODING: &'static str = "application/json";
112 type Output<S: BosStr> = EnableJoinLinkOutput<S>;
113 type Err = EnableJoinLinkError;
114}
115
116impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for EnableJoinLink<S> {
117 const NSID: &'static str = "chat.bsky.group.enableJoinLink";
118 const METHOD: jacquard_common::xrpc::XrpcMethod =
119 jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
120 type Response = EnableJoinLinkResponse;
121}
122
123pub struct EnableJoinLinkRequest;
127impl jacquard_common::xrpc::XrpcEndpoint for EnableJoinLinkRequest {
128 const PATH: &'static str = "/xrpc/chat.bsky.group.enableJoinLink";
129 const METHOD: jacquard_common::xrpc::XrpcMethod =
130 jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
131 type Request<S: BosStr> = EnableJoinLink<S>;
132 type Response = EnableJoinLinkResponse;
133}