Skip to main content

jacquard_api/chat_bsky/group/
list_join_requests.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: chat.bsky.group.listJoinRequests
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::JoinRequestView;
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)]
21#[serde(
22    rename_all = "camelCase",
23    bound(deserialize = "S: Deserialize<'de> + BosStr")
24)]
25pub struct ListJoinRequests<S: BosStr = DefaultStr> {
26    pub convo_id: S,
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub cursor: Option<S>,
29    /// Defaults to `50`. Min: 1. Max: 100.
30    #[serde(default = "_default_limit")]
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub limit: Option<i64>,
33}
34
35#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
36#[serde(
37    rename_all = "camelCase",
38    bound(deserialize = "S: Deserialize<'de> + BosStr")
39)]
40pub struct ListJoinRequestsOutput<S: BosStr = DefaultStr> {
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub cursor: Option<S>,
43    pub requests: Vec<JoinRequestView<S>>,
44    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
45    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
46}
47
48#[derive(
49    Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
50)]
51#[serde(tag = "error", content = "message")]
52pub enum ListJoinRequestsError {
53    #[serde(rename = "InvalidConvo")]
54    InvalidConvo(Option<SmolStr>),
55    #[serde(rename = "InsufficientRole")]
56    InsufficientRole(Option<SmolStr>),
57    /// Catch-all for unknown error codes.
58    #[serde(untagged)]
59    Other {
60        error: SmolStr,
61        message: Option<SmolStr>,
62    },
63}
64
65impl core::fmt::Display for ListJoinRequestsError {
66    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
67        match self {
68            Self::InvalidConvo(msg) => {
69                write!(f, "InvalidConvo")?;
70                if let Some(msg) = msg {
71                    write!(f, ": {}", msg)?;
72                }
73                Ok(())
74            }
75            Self::InsufficientRole(msg) => {
76                write!(f, "InsufficientRole")?;
77                if let Some(msg) = msg {
78                    write!(f, ": {}", msg)?;
79                }
80                Ok(())
81            }
82            Self::Other { error, message } => {
83                write!(f, "{}", error)?;
84                if let Some(msg) = message {
85                    write!(f, ": {}", msg)?;
86                }
87                Ok(())
88            }
89        }
90    }
91}
92
93/** Response marker for the `chat.bsky.group.listJoinRequests` query.
94
95Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `ListJoinRequestsOutput<S>` for this endpoint.*/
96pub struct ListJoinRequestsResponse;
97impl jacquard_common::xrpc::XrpcResp for ListJoinRequestsResponse {
98    const NSID: &'static str = "chat.bsky.group.listJoinRequests";
99    const ENCODING: &'static str = "application/json";
100    type Output<S: BosStr> = ListJoinRequestsOutput<S>;
101    type Err = ListJoinRequestsError;
102}
103
104impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ListJoinRequests<S> {
105    const NSID: &'static str = "chat.bsky.group.listJoinRequests";
106    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
107    type Response = ListJoinRequestsResponse;
108}
109
110/** Endpoint marker for the `chat.bsky.group.listJoinRequests` query.
111
112Path: `/xrpc/chat.bsky.group.listJoinRequests`. The request payload type is `ListJoinRequests<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
113pub struct ListJoinRequestsRequest;
114impl jacquard_common::xrpc::XrpcEndpoint for ListJoinRequestsRequest {
115    const PATH: &'static str = "/xrpc/chat.bsky.group.listJoinRequests";
116    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
117    type Request<S: BosStr> = ListJoinRequests<S>;
118    type Response = ListJoinRequestsResponse;
119}
120
121fn _default_limit() -> Option<i64> {
122    Some(50i64)
123}
124
125pub mod list_join_requests_state {
126
127    pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
128    #[allow(unused)]
129    use ::core::marker::PhantomData;
130    mod sealed {
131        pub trait Sealed {}
132    }
133    /// State trait tracking which required fields have been set
134    pub trait State: sealed::Sealed {
135        type ConvoId;
136    }
137    /// Empty state - all required fields are unset
138    pub struct Empty(());
139    impl sealed::Sealed for Empty {}
140    impl State for Empty {
141        type ConvoId = Unset;
142    }
143    ///State transition - sets the `convo_id` field to Set
144    pub struct SetConvoId<St: State = Empty>(PhantomData<fn() -> St>);
145    impl<St: State> sealed::Sealed for SetConvoId<St> {}
146    impl<St: State> State for SetConvoId<St> {
147        type ConvoId = Set<members::convo_id>;
148    }
149    /// Marker types for field names
150    #[allow(non_camel_case_types)]
151    pub mod members {
152        ///Marker type for the `convo_id` field
153        pub struct convo_id(());
154    }
155}
156
157/// Builder for constructing an instance of this type.
158pub struct ListJoinRequestsBuilder<St: list_join_requests_state::State, S: BosStr = DefaultStr> {
159    _state: PhantomData<fn() -> St>,
160    _fields: (Option<S>, Option<S>, Option<i64>),
161    _type: PhantomData<fn() -> S>,
162}
163
164impl ListJoinRequests<DefaultStr> {
165    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
166    pub fn new() -> ListJoinRequestsBuilder<list_join_requests_state::Empty, DefaultStr> {
167        ListJoinRequestsBuilder::new()
168    }
169}
170
171impl<S: BosStr> ListJoinRequests<S> {
172    /// Create a new builder for this type
173    pub fn builder() -> ListJoinRequestsBuilder<list_join_requests_state::Empty, S> {
174        ListJoinRequestsBuilder::builder()
175    }
176}
177
178impl ListJoinRequestsBuilder<list_join_requests_state::Empty, DefaultStr> {
179    /// Create a new builder with all fields unset, using the default string type, if needed
180    pub fn new() -> Self {
181        ListJoinRequestsBuilder {
182            _state: PhantomData,
183            _fields: (None, None, None),
184            _type: PhantomData,
185        }
186    }
187}
188
189impl<S: BosStr> ListJoinRequestsBuilder<list_join_requests_state::Empty, S> {
190    /// Create a new builder with all fields unset
191    pub fn builder() -> Self {
192        ListJoinRequestsBuilder {
193            _state: PhantomData,
194            _fields: (None, None, None),
195            _type: PhantomData,
196        }
197    }
198}
199
200impl<St, S: BosStr> ListJoinRequestsBuilder<St, S>
201where
202    St: list_join_requests_state::State,
203    St::ConvoId: list_join_requests_state::IsUnset,
204{
205    /// Set the `convoId` field (required)
206    pub fn convo_id(
207        mut self,
208        value: impl Into<S>,
209    ) -> ListJoinRequestsBuilder<list_join_requests_state::SetConvoId<St>, S> {
210        self._fields.0 = Option::Some(value.into());
211        ListJoinRequestsBuilder {
212            _state: PhantomData,
213            _fields: self._fields,
214            _type: PhantomData,
215        }
216    }
217}
218
219impl<St: list_join_requests_state::State, S: BosStr> ListJoinRequestsBuilder<St, S> {
220    /// Set the `cursor` field (optional)
221    pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
222        self._fields.1 = value.into();
223        self
224    }
225    /// Set the `cursor` field to an Option value (optional)
226    pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
227        self._fields.1 = value;
228        self
229    }
230}
231
232impl<St: list_join_requests_state::State, S: BosStr> ListJoinRequestsBuilder<St, S> {
233    /// Set the `limit` field (optional)
234    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
235        self._fields.2 = value.into();
236        self
237    }
238    /// Set the `limit` field to an Option value (optional)
239    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
240        self._fields.2 = value;
241        self
242    }
243}
244
245impl<St, S: BosStr> ListJoinRequestsBuilder<St, S>
246where
247    St: list_join_requests_state::State,
248    St::ConvoId: list_join_requests_state::IsSet,
249{
250    /// Build the final struct.
251    pub fn build(self) -> ListJoinRequests<S> {
252        ListJoinRequests {
253            convo_id: self._fields.0.unwrap(),
254            cursor: self._fields.1,
255            limit: self._fields.2,
256        }
257    }
258}