Skip to main content

jacquard_api/chat_bsky/group/
enable_join_link.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: chat.bsky.group.enableJoinLink
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[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    /// Catch-all for unknown error codes.
56    #[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
105/** Response marker for the `chat.bsky.group.enableJoinLink` procedure.
106
107Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `EnableJoinLinkOutput<S>` for this endpoint.*/
108pub 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
123/** Endpoint marker for the `chat.bsky.group.enableJoinLink` procedure.
124
125Path: `/xrpc/chat.bsky.group.enableJoinLink`. The request payload type is `EnableJoinLink<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
126pub 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}