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::{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 #[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
44pub 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
63pub 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 pub trait State: sealed::Sealed {
86 type Content;
87 type RecipientDid;
88 type SenderDid;
89 }
90 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 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 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 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 #[allow(non_camel_case_types)]
124 pub mod members {
125 pub struct content(());
127 pub struct recipient_did(());
129 pub struct sender_did(());
131 }
132}
133
134pub 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 pub fn new() -> SendEmailBuilder<send_email_state::Empty, DefaultStr> {
144 SendEmailBuilder::new()
145 }
146}
147
148impl<S: BosStr> SendEmail<S> {
149 pub fn builder() -> SendEmailBuilder<send_email_state::Empty, S> {
151 SendEmailBuilder::builder()
152 }
153}
154
155impl SendEmailBuilder<send_email_state::Empty, DefaultStr> {
156 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 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 pub fn comment(mut self, value: impl Into<Option<S>>) -> Self {
180 self._fields.0 = value.into();
181 self
182 }
183 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 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 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 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 pub fn subject(mut self, value: impl Into<Option<S>>) -> Self {
250 self._fields.4 = value.into();
251 self
252 }
253 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 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 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}