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