Skip to main content

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