#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
use jacquard_common::types::string::Did;
use jacquard_derive::{IntoStatic, lexicon};
use serde::{Serialize, Deserialize};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SendEmail<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub comment: Option<CowStr<'a>>,
#[serde(borrow)]
pub content: CowStr<'a>,
#[serde(borrow)]
pub recipient_did: Did<'a>,
#[serde(borrow)]
pub sender_did: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub subject: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SendEmailOutput<'a> {
pub sent: bool,
}
pub struct SendEmailResponse;
impl jacquard_common::xrpc::XrpcResp for SendEmailResponse {
const NSID: &'static str = "com.atproto.admin.sendEmail";
const ENCODING: &'static str = "application/json";
type Output<'de> = SendEmailOutput<'de>;
type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}
impl<'a> jacquard_common::xrpc::XrpcRequest for SendEmail<'a> {
const NSID: &'static str = "com.atproto.admin.sendEmail";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Response = SendEmailResponse;
}
pub struct SendEmailRequest;
impl jacquard_common::xrpc::XrpcEndpoint for SendEmailRequest {
const PATH: &'static str = "/xrpc/com.atproto.admin.sendEmail";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Procedure(
"application/json",
);
type Request<'de> = SendEmail<'de>;
type Response = SendEmailResponse;
}
pub mod send_email_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type RecipientDid;
type Content;
type SenderDid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type RecipientDid = Unset;
type Content = Unset;
type SenderDid = Unset;
}
pub struct SetRecipientDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRecipientDid<S> {}
impl<S: State> State for SetRecipientDid<S> {
type RecipientDid = Set<members::recipient_did>;
type Content = S::Content;
type SenderDid = S::SenderDid;
}
pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContent<S> {}
impl<S: State> State for SetContent<S> {
type RecipientDid = S::RecipientDid;
type Content = Set<members::content>;
type SenderDid = S::SenderDid;
}
pub struct SetSenderDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSenderDid<S> {}
impl<S: State> State for SetSenderDid<S> {
type RecipientDid = S::RecipientDid;
type Content = S::Content;
type SenderDid = Set<members::sender_did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct recipient_did(());
pub struct content(());
pub struct sender_did(());
}
}
pub struct SendEmailBuilder<'a, S: send_email_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Did<'a>>,
Option<Did<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> SendEmail<'a> {
pub fn new() -> SendEmailBuilder<'a, send_email_state::Empty> {
SendEmailBuilder::new()
}
}
impl<'a> SendEmailBuilder<'a, send_email_state::Empty> {
pub fn new() -> Self {
SendEmailBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: send_email_state::State> SendEmailBuilder<'a, S> {
pub fn comment(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_comment(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> SendEmailBuilder<'a, S>
where
S: send_email_state::State,
S::Content: send_email_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<CowStr<'a>>,
) -> SendEmailBuilder<'a, send_email_state::SetContent<S>> {
self._fields.1 = Option::Some(value.into());
SendEmailBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SendEmailBuilder<'a, S>
where
S: send_email_state::State,
S::RecipientDid: send_email_state::IsUnset,
{
pub fn recipient_did(
mut self,
value: impl Into<Did<'a>>,
) -> SendEmailBuilder<'a, send_email_state::SetRecipientDid<S>> {
self._fields.2 = Option::Some(value.into());
SendEmailBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SendEmailBuilder<'a, S>
where
S: send_email_state::State,
S::SenderDid: send_email_state::IsUnset,
{
pub fn sender_did(
mut self,
value: impl Into<Did<'a>>,
) -> SendEmailBuilder<'a, send_email_state::SetSenderDid<S>> {
self._fields.3 = Option::Some(value.into());
SendEmailBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: send_email_state::State> SendEmailBuilder<'a, S> {
pub fn subject(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_subject(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> SendEmailBuilder<'a, S>
where
S: send_email_state::State,
S::RecipientDid: send_email_state::IsSet,
S::Content: send_email_state::IsSet,
S::SenderDid: send_email_state::IsSet,
{
pub fn build(self) -> SendEmail<'a> {
SendEmail {
comment: self._fields.0,
content: self._fields.1.unwrap(),
recipient_did: self._fields.2.unwrap(),
sender_did: self._fields.3.unwrap(),
subject: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> SendEmail<'a> {
SendEmail {
comment: self._fields.0,
content: self._fields.1.unwrap(),
recipient_did: self._fields.2.unwrap(),
sender_did: self._fields.3.unwrap(),
subject: self._fields.4,
extra_data: Some(extra_data),
}
}
}