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