jacquard_api/com_atproto/admin/
send_email.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::deps::smol_str::SmolStr;
14use jacquard_common::types::string::Did;
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 SendEmail<S: BosStr = DefaultStr> {
26 #[serde(skip_serializing_if = "Option::is_none")]
28 pub comment: Option<S>,
29 pub content: S,
30 pub recipient_did: Did<S>,
31 pub sender_did: Did<S>,
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub subject: Option<S>,
34 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
35 pub extra_data: Option<BTreeMap<SmolStr, Data<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 SendEmailOutput<S: BosStr = DefaultStr> {
44 pub sent: bool,
45 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
46 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
47}
48
49pub struct SendEmailResponse;
53impl jacquard_common::xrpc::XrpcResp for SendEmailResponse {
54 const NSID: &'static str = "com.atproto.admin.sendEmail";
55 const ENCODING: &'static str = "application/json";
56 type Output<S: BosStr> = SendEmailOutput<S>;
57 type Err = jacquard_common::xrpc::GenericError;
58}
59
60impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for SendEmail<S> {
61 const NSID: &'static str = "com.atproto.admin.sendEmail";
62 const METHOD: jacquard_common::xrpc::XrpcMethod =
63 jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
64 type Response = SendEmailResponse;
65}
66
67pub struct SendEmailRequest;
71impl jacquard_common::xrpc::XrpcEndpoint for SendEmailRequest {
72 const PATH: &'static str = "/xrpc/com.atproto.admin.sendEmail";
73 const METHOD: jacquard_common::xrpc::XrpcMethod =
74 jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
75 type Request<S: BosStr> = SendEmail<S>;
76 type Response = SendEmailResponse;
77}
78
79pub mod send_email_state {
80
81 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
82 #[allow(unused)]
83 use ::core::marker::PhantomData;
84 mod sealed {
85 pub trait Sealed {}
86 }
87 pub trait State: sealed::Sealed {
89 type Content;
90 type RecipientDid;
91 type SenderDid;
92 }
93 pub struct Empty(());
95 impl sealed::Sealed for Empty {}
96 impl State for Empty {
97 type Content = Unset;
98 type RecipientDid = Unset;
99 type SenderDid = Unset;
100 }
101 pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
103 impl<St: State> sealed::Sealed for SetContent<St> {}
104 impl<St: State> State for SetContent<St> {
105 type Content = Set<members::content>;
106 type RecipientDid = St::RecipientDid;
107 type SenderDid = St::SenderDid;
108 }
109 pub struct SetRecipientDid<St: State = Empty>(PhantomData<fn() -> St>);
111 impl<St: State> sealed::Sealed for SetRecipientDid<St> {}
112 impl<St: State> State for SetRecipientDid<St> {
113 type Content = St::Content;
114 type RecipientDid = Set<members::recipient_did>;
115 type SenderDid = St::SenderDid;
116 }
117 pub struct SetSenderDid<St: State = Empty>(PhantomData<fn() -> St>);
119 impl<St: State> sealed::Sealed for SetSenderDid<St> {}
120 impl<St: State> State for SetSenderDid<St> {
121 type Content = St::Content;
122 type RecipientDid = St::RecipientDid;
123 type SenderDid = Set<members::sender_did>;
124 }
125 #[allow(non_camel_case_types)]
127 pub mod members {
128 pub struct content(());
130 pub struct recipient_did(());
132 pub struct sender_did(());
134 }
135}
136
137pub struct SendEmailBuilder<St: send_email_state::State, S: BosStr = DefaultStr> {
139 _state: PhantomData<fn() -> St>,
140 _fields: (
141 Option<S>,
142 Option<S>,
143 Option<Did<S>>,
144 Option<Did<S>>,
145 Option<S>,
146 ),
147 _type: PhantomData<fn() -> S>,
148}
149
150impl SendEmail<DefaultStr> {
151 pub fn new() -> SendEmailBuilder<send_email_state::Empty, DefaultStr> {
153 SendEmailBuilder::new()
154 }
155}
156
157impl<S: BosStr> SendEmail<S> {
158 pub fn builder() -> SendEmailBuilder<send_email_state::Empty, S> {
160 SendEmailBuilder::builder()
161 }
162}
163
164impl SendEmailBuilder<send_email_state::Empty, DefaultStr> {
165 pub fn new() -> Self {
167 SendEmailBuilder {
168 _state: PhantomData,
169 _fields: (None, None, None, None, None),
170 _type: PhantomData,
171 }
172 }
173}
174
175impl<S: BosStr> SendEmailBuilder<send_email_state::Empty, S> {
176 pub fn builder() -> Self {
178 SendEmailBuilder {
179 _state: PhantomData,
180 _fields: (None, None, None, None, None),
181 _type: PhantomData,
182 }
183 }
184}
185
186impl<St: send_email_state::State, S: BosStr> SendEmailBuilder<St, S> {
187 pub fn comment(mut self, value: impl Into<Option<S>>) -> Self {
189 self._fields.0 = value.into();
190 self
191 }
192 pub fn maybe_comment(mut self, value: Option<S>) -> Self {
194 self._fields.0 = value;
195 self
196 }
197}
198
199impl<St, S: BosStr> SendEmailBuilder<St, S>
200where
201 St: send_email_state::State,
202 St::Content: send_email_state::IsUnset,
203{
204 pub fn content(
206 mut self,
207 value: impl Into<S>,
208 ) -> SendEmailBuilder<send_email_state::SetContent<St>, S> {
209 self._fields.1 = Option::Some(value.into());
210 SendEmailBuilder {
211 _state: PhantomData,
212 _fields: self._fields,
213 _type: PhantomData,
214 }
215 }
216}
217
218impl<St, S: BosStr> SendEmailBuilder<St, S>
219where
220 St: send_email_state::State,
221 St::RecipientDid: send_email_state::IsUnset,
222{
223 pub fn recipient_did(
225 mut self,
226 value: impl Into<Did<S>>,
227 ) -> SendEmailBuilder<send_email_state::SetRecipientDid<St>, S> {
228 self._fields.2 = Option::Some(value.into());
229 SendEmailBuilder {
230 _state: PhantomData,
231 _fields: self._fields,
232 _type: PhantomData,
233 }
234 }
235}
236
237impl<St, S: BosStr> SendEmailBuilder<St, S>
238where
239 St: send_email_state::State,
240 St::SenderDid: send_email_state::IsUnset,
241{
242 pub fn sender_did(
244 mut self,
245 value: impl Into<Did<S>>,
246 ) -> SendEmailBuilder<send_email_state::SetSenderDid<St>, S> {
247 self._fields.3 = Option::Some(value.into());
248 SendEmailBuilder {
249 _state: PhantomData,
250 _fields: self._fields,
251 _type: PhantomData,
252 }
253 }
254}
255
256impl<St: send_email_state::State, S: BosStr> SendEmailBuilder<St, S> {
257 pub fn subject(mut self, value: impl Into<Option<S>>) -> Self {
259 self._fields.4 = value.into();
260 self
261 }
262 pub fn maybe_subject(mut self, value: Option<S>) -> Self {
264 self._fields.4 = value;
265 self
266 }
267}
268
269impl<St, S: BosStr> SendEmailBuilder<St, S>
270where
271 St: send_email_state::State,
272 St::Content: send_email_state::IsSet,
273 St::RecipientDid: send_email_state::IsSet,
274 St::SenderDid: send_email_state::IsSet,
275{
276 pub fn build(self) -> SendEmail<S> {
278 SendEmail {
279 comment: self._fields.0,
280 content: self._fields.1.unwrap(),
281 recipient_did: self._fields.2.unwrap(),
282 sender_did: self._fields.3.unwrap(),
283 subject: self._fields.4,
284 extra_data: Default::default(),
285 }
286 }
287 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> SendEmail<S> {
289 SendEmail {
290 comment: self._fields.0,
291 content: self._fields.1.unwrap(),
292 recipient_did: self._fields.2.unwrap(),
293 sender_did: self._fields.3.unwrap(),
294 subject: self._fields.4,
295 extra_data: Some(extra_data),
296 }
297 }
298}