use crate::Channel;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SmsMessage {
to: String,
body: String,
}
impl SmsMessage {
#[must_use]
pub fn new(to: impl Into<String>, body: impl Into<String>) -> Self {
Self {
to: to.into(),
body: body.into(),
}
}
#[must_use]
pub fn to(&self) -> &str {
&self.to
}
#[must_use]
pub fn body(&self) -> &str {
&self.body
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct PushMessage {
device_token: String,
title: String,
body: String,
}
impl PushMessage {
#[must_use]
pub fn new(
device_token: impl Into<String>,
title: impl Into<String>,
body: impl Into<String>,
) -> Self {
Self {
device_token: device_token.into(),
title: title.into(),
body: body.into(),
}
}
#[must_use]
pub fn device_token(&self) -> &str {
&self.device_token
}
#[must_use]
pub fn title(&self) -> &str {
&self.title
}
#[must_use]
pub fn body(&self) -> &str {
&self.body
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Notification {
Sms(SmsMessage),
Push(PushMessage),
}
impl Notification {
#[must_use]
pub const fn channel(&self) -> Channel {
match self {
Self::Sms(_) => Channel::Sms,
Self::Push(_) => Channel::Push,
}
}
#[must_use]
pub fn sms(to: impl Into<String>, body: impl Into<String>) -> Self {
Self::Sms(SmsMessage::new(to, body))
}
#[must_use]
pub fn push(
device_token: impl Into<String>,
title: impl Into<String>,
body: impl Into<String>,
) -> Self {
Self::Push(PushMessage::new(device_token, title, body))
}
}