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