#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::Did;
use jacquard_common::types::value::Data;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
use jacquard_derive::IntoStatic;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SendEmail<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<S>,
pub content: S,
pub recipient_did: Did<S>,
pub sender_did: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct SendEmailOutput<S: BosStr = DefaultStr> {
pub sent: bool,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
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<S: BosStr> = SendEmailOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for SendEmail<S> {
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<S: BosStr> = SendEmail<S>;
type Response = SendEmailResponse;
}
pub mod send_email_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type SenderDid;
type Content;
type RecipientDid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type SenderDid = Unset;
type Content = Unset;
type RecipientDid = Unset;
}
pub struct SetSenderDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSenderDid<St> {}
impl<St: State> State for SetSenderDid<St> {
type SenderDid = Set<members::sender_did>;
type Content = St::Content;
type RecipientDid = St::RecipientDid;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type SenderDid = St::SenderDid;
type Content = Set<members::content>;
type RecipientDid = St::RecipientDid;
}
pub struct SetRecipientDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRecipientDid<St> {}
impl<St: State> State for SetRecipientDid<St> {
type SenderDid = St::SenderDid;
type Content = St::Content;
type RecipientDid = Set<members::recipient_did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct sender_did(());
pub struct content(());
pub struct recipient_did(());
}
}
pub struct SendEmailBuilder<S: BosStr, St: send_email_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<S>,
Option<Did<S>>,
Option<Did<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SendEmail<S> {
pub fn new() -> SendEmailBuilder<S, send_email_state::Empty> {
SendEmailBuilder::new()
}
}
impl<S: BosStr> SendEmailBuilder<S, send_email_state::Empty> {
pub fn new() -> Self {
SendEmailBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: send_email_state::State> SendEmailBuilder<S, St> {
pub fn comment(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_comment(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> SendEmailBuilder<S, St>
where
St: send_email_state::State,
St::Content: send_email_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<S>,
) -> SendEmailBuilder<S, send_email_state::SetContent<St>> {
self._fields.1 = Option::Some(value.into());
SendEmailBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SendEmailBuilder<S, St>
where
St: send_email_state::State,
St::RecipientDid: send_email_state::IsUnset,
{
pub fn recipient_did(
mut self,
value: impl Into<Did<S>>,
) -> SendEmailBuilder<S, send_email_state::SetRecipientDid<St>> {
self._fields.2 = Option::Some(value.into());
SendEmailBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SendEmailBuilder<S, St>
where
St: send_email_state::State,
St::SenderDid: send_email_state::IsUnset,
{
pub fn sender_did(
mut self,
value: impl Into<Did<S>>,
) -> SendEmailBuilder<S, send_email_state::SetSenderDid<St>> {
self._fields.3 = Option::Some(value.into());
SendEmailBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: send_email_state::State> SendEmailBuilder<S, St> {
pub fn subject(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_subject(mut self, value: Option<S>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> SendEmailBuilder<S, St>
where
St: send_email_state::State,
St::SenderDid: send_email_state::IsSet,
St::Content: send_email_state::IsSet,
St::RecipientDid: send_email_state::IsSet,
{
pub fn build(self) -> SendEmail<S> {
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<SmolStr, Data<S>>) -> SendEmail<S> {
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),
}
}
}