use serde::Serialize;
#[derive(Serialize, Debug, Default)]
pub struct MailSettings {
bcc: Option<BccSetting>,
bypass_list_management: Option<BypassListSetting>,
footer: Option<FooterSetting>,
sandbox_mode: Option<SandboxModeSetting>,
spam_check: Option<SpamCheckSetting>,
}
#[derive(Default)]
pub struct MailSettingsBuilder {
settings: MailSettings,
}
impl MailSettingsBuilder {
pub fn bcc(mut self, email: impl Into<String>) -> Self {
self.settings.bcc = Some(BccSetting {
enable: true,
email: email.into(),
});
self
}
pub fn bypass_list_management(mut self) -> Self {
self.settings.bypass_list_management = Some(BypassListSetting { enable: true });
self
}
pub fn footer(mut self, text: Option<String>, html: Option<String>) -> Self {
self.settings.footer = Some(FooterSetting {
enable: true,
text,
html,
});
self
}
pub fn sandbox_mode(mut self) -> Self {
self.settings.sandbox_mode = Some(SandboxModeSetting { enable: true });
self
}
pub fn spam_check(mut self, threshold: Option<i32>, post_to_url: Option<String>) -> Self {
self.settings.spam_check = Some(SpamCheckSetting {
enable: true,
threshold,
post_to_url,
});
self
}
pub fn build(self) -> MailSettings {
self.settings
}
}
#[derive(Serialize, Debug)]
pub struct BccSetting {
enable: bool,
email: String,
}
#[derive(Serialize, Debug)]
pub struct BypassListSetting {
enable: bool,
}
#[derive(Serialize, Debug)]
pub struct FooterSetting {
enable: bool,
text: Option<String>,
html: Option<String>,
}
#[derive(Serialize, Debug)]
pub struct SandboxModeSetting {
enable: bool,
}
#[derive(Serialize, Debug)]
pub struct SpamCheckSetting {
enable: bool,
threshold: Option<i32>,
post_to_url: Option<String>,
}