jacquard_api/com_atproto/admin/
send_email.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.admin.sendEmail
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct SendEmail<'a> {
20    /// Additional comment by the sender that won't be used in the email itself but helpful to provide more context for moderators/reviewers
21    #[serde(skip_serializing_if = "std::option::Option::is_none")]
22    #[serde(borrow)]
23    pub comment: Option<jacquard_common::CowStr<'a>>,
24    #[serde(borrow)]
25    pub content: jacquard_common::CowStr<'a>,
26    #[serde(borrow)]
27    pub recipient_did: jacquard_common::types::string::Did<'a>,
28    #[serde(borrow)]
29    pub sender_did: jacquard_common::types::string::Did<'a>,
30    #[serde(skip_serializing_if = "std::option::Option::is_none")]
31    #[serde(borrow)]
32    pub subject: Option<jacquard_common::CowStr<'a>>,
33}
34
35pub mod send_email_state {
36
37    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
38    #[allow(unused)]
39    use ::core::marker::PhantomData;
40    mod sealed {
41        pub trait Sealed {}
42    }
43    /// State trait tracking which required fields have been set
44    pub trait State: sealed::Sealed {
45        type RecipientDid;
46        type Content;
47        type SenderDid;
48    }
49    /// Empty state - all required fields are unset
50    pub struct Empty(());
51    impl sealed::Sealed for Empty {}
52    impl State for Empty {
53        type RecipientDid = Unset;
54        type Content = Unset;
55        type SenderDid = Unset;
56    }
57    ///State transition - sets the `recipient_did` field to Set
58    pub struct SetRecipientDid<S: State = Empty>(PhantomData<fn() -> S>);
59    impl<S: State> sealed::Sealed for SetRecipientDid<S> {}
60    impl<S: State> State for SetRecipientDid<S> {
61        type RecipientDid = Set<members::recipient_did>;
62        type Content = S::Content;
63        type SenderDid = S::SenderDid;
64    }
65    ///State transition - sets the `content` field to Set
66    pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
67    impl<S: State> sealed::Sealed for SetContent<S> {}
68    impl<S: State> State for SetContent<S> {
69        type RecipientDid = S::RecipientDid;
70        type Content = Set<members::content>;
71        type SenderDid = S::SenderDid;
72    }
73    ///State transition - sets the `sender_did` field to Set
74    pub struct SetSenderDid<S: State = Empty>(PhantomData<fn() -> S>);
75    impl<S: State> sealed::Sealed for SetSenderDid<S> {}
76    impl<S: State> State for SetSenderDid<S> {
77        type RecipientDid = S::RecipientDid;
78        type Content = S::Content;
79        type SenderDid = Set<members::sender_did>;
80    }
81    /// Marker types for field names
82    #[allow(non_camel_case_types)]
83    pub mod members {
84        ///Marker type for the `recipient_did` field
85        pub struct recipient_did(());
86        ///Marker type for the `content` field
87        pub struct content(());
88        ///Marker type for the `sender_did` field
89        pub struct sender_did(());
90    }
91}
92
93/// Builder for constructing an instance of this type
94pub struct SendEmailBuilder<'a, S: send_email_state::State> {
95    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
96    __unsafe_private_named: (
97        ::core::option::Option<jacquard_common::CowStr<'a>>,
98        ::core::option::Option<jacquard_common::CowStr<'a>>,
99        ::core::option::Option<jacquard_common::types::string::Did<'a>>,
100        ::core::option::Option<jacquard_common::types::string::Did<'a>>,
101        ::core::option::Option<jacquard_common::CowStr<'a>>,
102    ),
103    _phantom: ::core::marker::PhantomData<&'a ()>,
104}
105
106impl<'a> SendEmail<'a> {
107    /// Create a new builder for this type
108    pub fn new() -> SendEmailBuilder<'a, send_email_state::Empty> {
109        SendEmailBuilder::new()
110    }
111}
112
113impl<'a> SendEmailBuilder<'a, send_email_state::Empty> {
114    /// Create a new builder with all fields unset
115    pub fn new() -> Self {
116        SendEmailBuilder {
117            _phantom_state: ::core::marker::PhantomData,
118            __unsafe_private_named: (None, None, None, None, None),
119            _phantom: ::core::marker::PhantomData,
120        }
121    }
122}
123
124impl<'a, S: send_email_state::State> SendEmailBuilder<'a, S> {
125    /// Set the `comment` field (optional)
126    pub fn comment(
127        mut self,
128        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
129    ) -> Self {
130        self.__unsafe_private_named.0 = value.into();
131        self
132    }
133    /// Set the `comment` field to an Option value (optional)
134    pub fn maybe_comment(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
135        self.__unsafe_private_named.0 = value;
136        self
137    }
138}
139
140impl<'a, S> SendEmailBuilder<'a, S>
141where
142    S: send_email_state::State,
143    S::Content: send_email_state::IsUnset,
144{
145    /// Set the `content` field (required)
146    pub fn content(
147        mut self,
148        value: impl Into<jacquard_common::CowStr<'a>>,
149    ) -> SendEmailBuilder<'a, send_email_state::SetContent<S>> {
150        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
151        SendEmailBuilder {
152            _phantom_state: ::core::marker::PhantomData,
153            __unsafe_private_named: self.__unsafe_private_named,
154            _phantom: ::core::marker::PhantomData,
155        }
156    }
157}
158
159impl<'a, S> SendEmailBuilder<'a, S>
160where
161    S: send_email_state::State,
162    S::RecipientDid: send_email_state::IsUnset,
163{
164    /// Set the `recipientDid` field (required)
165    pub fn recipient_did(
166        mut self,
167        value: impl Into<jacquard_common::types::string::Did<'a>>,
168    ) -> SendEmailBuilder<'a, send_email_state::SetRecipientDid<S>> {
169        self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
170        SendEmailBuilder {
171            _phantom_state: ::core::marker::PhantomData,
172            __unsafe_private_named: self.__unsafe_private_named,
173            _phantom: ::core::marker::PhantomData,
174        }
175    }
176}
177
178impl<'a, S> SendEmailBuilder<'a, S>
179where
180    S: send_email_state::State,
181    S::SenderDid: send_email_state::IsUnset,
182{
183    /// Set the `senderDid` field (required)
184    pub fn sender_did(
185        mut self,
186        value: impl Into<jacquard_common::types::string::Did<'a>>,
187    ) -> SendEmailBuilder<'a, send_email_state::SetSenderDid<S>> {
188        self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
189        SendEmailBuilder {
190            _phantom_state: ::core::marker::PhantomData,
191            __unsafe_private_named: self.__unsafe_private_named,
192            _phantom: ::core::marker::PhantomData,
193        }
194    }
195}
196
197impl<'a, S: send_email_state::State> SendEmailBuilder<'a, S> {
198    /// Set the `subject` field (optional)
199    pub fn subject(
200        mut self,
201        value: impl Into<Option<jacquard_common::CowStr<'a>>>,
202    ) -> Self {
203        self.__unsafe_private_named.4 = value.into();
204        self
205    }
206    /// Set the `subject` field to an Option value (optional)
207    pub fn maybe_subject(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
208        self.__unsafe_private_named.4 = value;
209        self
210    }
211}
212
213impl<'a, S> SendEmailBuilder<'a, S>
214where
215    S: send_email_state::State,
216    S::RecipientDid: send_email_state::IsSet,
217    S::Content: send_email_state::IsSet,
218    S::SenderDid: send_email_state::IsSet,
219{
220    /// Build the final struct
221    pub fn build(self) -> SendEmail<'a> {
222        SendEmail {
223            comment: self.__unsafe_private_named.0,
224            content: self.__unsafe_private_named.1.unwrap(),
225            recipient_did: self.__unsafe_private_named.2.unwrap(),
226            sender_did: self.__unsafe_private_named.3.unwrap(),
227            subject: self.__unsafe_private_named.4,
228            extra_data: Default::default(),
229        }
230    }
231    /// Build the final struct with custom extra_data
232    pub fn build_with_data(
233        self,
234        extra_data: std::collections::BTreeMap<
235            jacquard_common::smol_str::SmolStr,
236            jacquard_common::types::value::Data<'a>,
237        >,
238    ) -> SendEmail<'a> {
239        SendEmail {
240            comment: self.__unsafe_private_named.0,
241            content: self.__unsafe_private_named.1.unwrap(),
242            recipient_did: self.__unsafe_private_named.2.unwrap(),
243            sender_did: self.__unsafe_private_named.3.unwrap(),
244            subject: self.__unsafe_private_named.4,
245            extra_data: Some(extra_data),
246        }
247    }
248}
249
250#[jacquard_derive::lexicon]
251#[derive(
252    serde::Serialize,
253    serde::Deserialize,
254    Debug,
255    Clone,
256    PartialEq,
257    Eq,
258    jacquard_derive::IntoStatic
259)]
260#[serde(rename_all = "camelCase")]
261pub struct SendEmailOutput<'a> {
262    pub sent: bool,
263}
264
265/// Response type for
266///com.atproto.admin.sendEmail
267pub struct SendEmailResponse;
268impl jacquard_common::xrpc::XrpcResp for SendEmailResponse {
269    const NSID: &'static str = "com.atproto.admin.sendEmail";
270    const ENCODING: &'static str = "application/json";
271    type Output<'de> = SendEmailOutput<'de>;
272    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
273}
274
275impl<'a> jacquard_common::xrpc::XrpcRequest for SendEmail<'a> {
276    const NSID: &'static str = "com.atproto.admin.sendEmail";
277    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
278        "application/json",
279    );
280    type Response = SendEmailResponse;
281}
282
283/// Endpoint type for
284///com.atproto.admin.sendEmail
285pub struct SendEmailRequest;
286impl jacquard_common::xrpc::XrpcEndpoint for SendEmailRequest {
287    const PATH: &'static str = "/xrpc/com.atproto.admin.sendEmail";
288    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
289        "application/json",
290    );
291    type Request<'de> = SendEmail<'de>;
292    type Response = SendEmailResponse;
293}