jacquard_api/com_atproto/server/
get_account_invite_codes.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_derive::{IntoStatic, lexicon, open_union};
15use serde::{Serialize, Deserialize};
16use crate::com_atproto::server::InviteCode;
17
18#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
19#[serde(rename_all = "camelCase")]
20pub struct GetAccountInviteCodes {
21 #[serde(default = "_default_create_available")]
23 #[serde(skip_serializing_if = "Option::is_none")]
24 pub create_available: Option<bool>,
25 #[serde(default = "_default_include_used")]
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub include_used: Option<bool>,
29}
30
31
32#[lexicon]
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
34#[serde(rename_all = "camelCase")]
35pub struct GetAccountInviteCodesOutput<'a> {
36 #[serde(borrow)]
37 pub codes: Vec<InviteCode<'a>>,
38}
39
40
41#[open_union]
42#[derive(
43 Serialize,
44 Deserialize,
45 Debug,
46 Clone,
47 PartialEq,
48 Eq,
49 thiserror::Error,
50 miette::Diagnostic,
51 IntoStatic
52)]
53
54#[serde(tag = "error", content = "message")]
55#[serde(bound(deserialize = "'de: 'a"))]
56pub enum GetAccountInviteCodesError<'a> {
57 #[serde(rename = "DuplicateCreate")]
58 DuplicateCreate(Option<CowStr<'a>>),
59}
60
61impl core::fmt::Display for GetAccountInviteCodesError<'_> {
62 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
63 match self {
64 Self::DuplicateCreate(msg) => {
65 write!(f, "DuplicateCreate")?;
66 if let Some(msg) = msg {
67 write!(f, ": {}", msg)?;
68 }
69 Ok(())
70 }
71 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
72 }
73 }
74}
75
76pub struct GetAccountInviteCodesResponse;
78impl jacquard_common::xrpc::XrpcResp for GetAccountInviteCodesResponse {
79 const NSID: &'static str = "com.atproto.server.getAccountInviteCodes";
80 const ENCODING: &'static str = "application/json";
81 type Output<'de> = GetAccountInviteCodesOutput<'de>;
82 type Err<'de> = GetAccountInviteCodesError<'de>;
83}
84
85impl jacquard_common::xrpc::XrpcRequest for GetAccountInviteCodes {
86 const NSID: &'static str = "com.atproto.server.getAccountInviteCodes";
87 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
88 type Response = GetAccountInviteCodesResponse;
89}
90
91pub struct GetAccountInviteCodesRequest;
93impl jacquard_common::xrpc::XrpcEndpoint for GetAccountInviteCodesRequest {
94 const PATH: &'static str = "/xrpc/com.atproto.server.getAccountInviteCodes";
95 const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
96 type Request<'de> = GetAccountInviteCodes;
97 type Response = GetAccountInviteCodesResponse;
98}
99
100fn _default_create_available() -> Option<bool> {
101 Some(true)
102}
103
104fn _default_include_used() -> Option<bool> {
105 Some(true)
106}
107
108pub mod get_account_invite_codes_state {
109
110 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
111 #[allow(unused)]
112 use ::core::marker::PhantomData;
113 mod sealed {
114 pub trait Sealed {}
115 }
116 pub trait State: sealed::Sealed {}
118 pub struct Empty(());
120 impl sealed::Sealed for Empty {}
121 impl State for Empty {}
122 #[allow(non_camel_case_types)]
124 pub mod members {}
125}
126
127pub struct GetAccountInviteCodesBuilder<S: get_account_invite_codes_state::State> {
129 _state: PhantomData<fn() -> S>,
130 _fields: (Option<bool>, Option<bool>),
131}
132
133impl GetAccountInviteCodes {
134 pub fn new() -> GetAccountInviteCodesBuilder<get_account_invite_codes_state::Empty> {
136 GetAccountInviteCodesBuilder::new()
137 }
138}
139
140impl GetAccountInviteCodesBuilder<get_account_invite_codes_state::Empty> {
141 pub fn new() -> Self {
143 GetAccountInviteCodesBuilder {
144 _state: PhantomData,
145 _fields: (None, None),
146 }
147 }
148}
149
150impl<S: get_account_invite_codes_state::State> GetAccountInviteCodesBuilder<S> {
151 pub fn create_available(mut self, value: impl Into<Option<bool>>) -> Self {
153 self._fields.0 = value.into();
154 self
155 }
156 pub fn maybe_create_available(mut self, value: Option<bool>) -> Self {
158 self._fields.0 = value;
159 self
160 }
161}
162
163impl<S: get_account_invite_codes_state::State> GetAccountInviteCodesBuilder<S> {
164 pub fn include_used(mut self, value: impl Into<Option<bool>>) -> Self {
166 self._fields.1 = value.into();
167 self
168 }
169 pub fn maybe_include_used(mut self, value: Option<bool>) -> Self {
171 self._fields.1 = value;
172 self
173 }
174}
175
176impl<S> GetAccountInviteCodesBuilder<S>
177where
178 S: get_account_invite_codes_state::State,
179{
180 pub fn build(self) -> GetAccountInviteCodes {
182 GetAccountInviteCodes {
183 create_available: self._fields.0,
184 include_used: self._fields.1,
185 }
186 }
187}