Skip to main content

jacquard_api/com_atproto/admin/
get_invite_codes.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.admin.getInviteCodes
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::com_atproto::server::InviteCode;
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;
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 GetInviteCodes<S: BosStr = DefaultStr> {
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub cursor: Option<S>,
28    /// Defaults to `100`. Min: 1. Max: 500.
29    #[serde(default = "_default_limit")]
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub limit: Option<i64>,
32    /// Defaults to `"recent"`.
33    #[serde(default = "_default_sort")]
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub sort: Option<S>,
36}
37
38#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
39#[serde(
40    rename_all = "camelCase",
41    bound(deserialize = "S: Deserialize<'de> + BosStr")
42)]
43pub struct GetInviteCodesOutput<S: BosStr = DefaultStr> {
44    pub codes: Vec<InviteCode<S>>,
45    #[serde(skip_serializing_if = "Option::is_none")]
46    pub cursor: Option<S>,
47    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
48    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
49}
50
51/** Response marker for the `com.atproto.admin.getInviteCodes` query.
52
53Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetInviteCodesOutput<S>` for this endpoint.*/
54pub struct GetInviteCodesResponse;
55impl jacquard_common::xrpc::XrpcResp for GetInviteCodesResponse {
56    const NSID: &'static str = "com.atproto.admin.getInviteCodes";
57    const ENCODING: &'static str = "application/json";
58    type Output<S: BosStr> = GetInviteCodesOutput<S>;
59    type Err = jacquard_common::xrpc::GenericError;
60}
61
62impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetInviteCodes<S> {
63    const NSID: &'static str = "com.atproto.admin.getInviteCodes";
64    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
65    type Response = GetInviteCodesResponse;
66}
67
68/** Endpoint marker for the `com.atproto.admin.getInviteCodes` query.
69
70Path: `/xrpc/com.atproto.admin.getInviteCodes`. The request payload type is `GetInviteCodes<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
71pub struct GetInviteCodesRequest;
72impl jacquard_common::xrpc::XrpcEndpoint for GetInviteCodesRequest {
73    const PATH: &'static str = "/xrpc/com.atproto.admin.getInviteCodes";
74    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
75    type Request<S: BosStr> = GetInviteCodes<S>;
76    type Response = GetInviteCodesResponse;
77}
78
79fn _default_limit() -> Option<i64> {
80    Some(100i64)
81}
82
83fn _default_sort<S: jacquard_common::FromStaticStr>() -> Option<S> {
84    Some(S::from_static("recent"))
85}
86
87pub mod get_invite_codes_state {
88
89    pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
90    #[allow(unused)]
91    use ::core::marker::PhantomData;
92    mod sealed {
93        pub trait Sealed {}
94    }
95    /// State trait tracking which required fields have been set
96    pub trait State: sealed::Sealed {}
97    /// Empty state - all required fields are unset
98    pub struct Empty(());
99    impl sealed::Sealed for Empty {}
100    impl State for Empty {}
101    /// Marker types for field names
102    #[allow(non_camel_case_types)]
103    pub mod members {}
104}
105
106/// Builder for constructing an instance of this type.
107pub struct GetInviteCodesBuilder<St: get_invite_codes_state::State, S: BosStr = DefaultStr> {
108    _state: PhantomData<fn() -> St>,
109    _fields: (Option<S>, Option<i64>, Option<S>),
110    _type: PhantomData<fn() -> S>,
111}
112
113impl GetInviteCodes<DefaultStr> {
114    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
115    pub fn new() -> GetInviteCodesBuilder<get_invite_codes_state::Empty, DefaultStr> {
116        GetInviteCodesBuilder::new()
117    }
118}
119
120impl<S: BosStr> GetInviteCodes<S> {
121    /// Create a new builder for this type
122    pub fn builder() -> GetInviteCodesBuilder<get_invite_codes_state::Empty, S> {
123        GetInviteCodesBuilder::builder()
124    }
125}
126
127impl GetInviteCodesBuilder<get_invite_codes_state::Empty, DefaultStr> {
128    /// Create a new builder with all fields unset, using the default string type, if needed
129    pub fn new() -> Self {
130        GetInviteCodesBuilder {
131            _state: PhantomData,
132            _fields: (None, None, None),
133            _type: PhantomData,
134        }
135    }
136}
137
138impl<S: BosStr> GetInviteCodesBuilder<get_invite_codes_state::Empty, S> {
139    /// Create a new builder with all fields unset
140    pub fn builder() -> Self {
141        GetInviteCodesBuilder {
142            _state: PhantomData,
143            _fields: (None, None, None),
144            _type: PhantomData,
145        }
146    }
147}
148
149impl<St: get_invite_codes_state::State, S: BosStr> GetInviteCodesBuilder<St, S> {
150    /// Set the `cursor` field (optional)
151    pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
152        self._fields.0 = value.into();
153        self
154    }
155    /// Set the `cursor` field to an Option value (optional)
156    pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
157        self._fields.0 = value;
158        self
159    }
160}
161
162impl<St: get_invite_codes_state::State, S: BosStr> GetInviteCodesBuilder<St, S> {
163    /// Set the `limit` field (optional)
164    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
165        self._fields.1 = value.into();
166        self
167    }
168    /// Set the `limit` field to an Option value (optional)
169    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
170        self._fields.1 = value;
171        self
172    }
173}
174
175impl<St: get_invite_codes_state::State, S: BosStr> GetInviteCodesBuilder<St, S> {
176    /// Set the `sort` field (optional)
177    pub fn sort(mut self, value: impl Into<Option<S>>) -> Self {
178        self._fields.2 = value.into();
179        self
180    }
181    /// Set the `sort` field to an Option value (optional)
182    pub fn maybe_sort(mut self, value: Option<S>) -> Self {
183        self._fields.2 = value;
184        self
185    }
186}
187
188impl<St, S: BosStr> GetInviteCodesBuilder<St, S>
189where
190    St: get_invite_codes_state::State,
191{
192    /// Build the final struct.
193    pub fn build(self) -> GetInviteCodes<S> {
194        GetInviteCodes {
195            cursor: self._fields.0,
196            limit: self._fields.1,
197            sort: self._fields.2,
198        }
199    }
200}