use crate::{Level, Notification};
#[derive(Debug, Default, Clone)]
pub struct NotificationBuilder {
device_key: Option<String>,
device_keys: Option<Vec<String>>,
title: Option<String>,
subtitle: Option<String>,
body: Option<String>,
markdown: Option<String>,
image: Option<String>,
sound: Option<String>,
badge: Option<i32>,
icon: Option<String>,
group: Option<String>,
url: Option<String>,
copy: Option<String>,
action: Option<String>,
is_archive: Option<i32>,
is_url_encode: Option<i32>,
auto_copy: Option<i32>,
level: Option<Level>,
volume: Option<i32>,
call: Option<i32>,
id: Option<String>,
delete: Option<i32>,
ttl: Option<i32>,
}
impl NotificationBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn device_key(mut self, key: impl Into<String>) -> Self {
self.device_key = Some(key.into());
self
}
pub fn device_keys(mut self, keys: Vec<String>) -> Self {
self.device_keys = Some(keys);
self
}
pub fn title(mut self, title: impl Into<String>) -> Self {
self.title = Some(title.into());
self
}
pub fn body(mut self, body: impl Into<String>) -> Self {
self.body = Some(body.into());
self
}
pub fn subtitle(mut self, subtitle: impl Into<String>) -> Self {
self.subtitle = Some(subtitle.into());
self
}
pub fn markdown(mut self, markdown: impl Into<String>) -> Self {
self.markdown = Some(markdown.into());
self
}
pub fn image(mut self, image: impl Into<String>) -> Self {
self.image = Some(image.into());
self
}
pub fn sound(mut self, sound: impl Into<String>) -> Self {
self.sound = Some(sound.into());
self
}
pub fn badge(mut self, badge: i32) -> Self {
self.badge = Some(badge);
self
}
pub fn icon(mut self, icon: impl Into<String>) -> Self {
self.icon = Some(icon.into());
self
}
pub fn group(mut self, group: impl Into<String>) -> Self {
self.group = Some(group.into());
self
}
pub fn url(mut self, url: impl Into<String>) -> Self {
self.url = Some(url.into());
self
}
pub fn copy(mut self, copy: impl Into<String>) -> Self {
self.copy = Some(copy.into());
self
}
pub fn action(mut self, action: impl Into<String>) -> Self {
self.action = Some(action.into());
self
}
pub fn archive(mut self, archive: bool) -> Self {
self.is_archive = Some(if archive { 1 } else { 0 });
self
}
pub fn url_encode(mut self, encode: bool) -> Self {
self.is_url_encode = Some(if encode { 1 } else { 0 });
self
}
pub fn auto_copy(mut self, auto_copy: bool) -> Self {
self.auto_copy = Some(if auto_copy { 1 } else { 0 });
self
}
pub fn level(mut self, level: Level) -> Self {
self.level = Some(level);
self
}
pub fn volume(mut self, volume: i32) -> Self {
self.volume = Some(volume);
self
}
pub fn call(mut self, call: bool) -> Self {
self.call = Some(if call { 1 } else { 0 });
self
}
pub fn id(mut self, id: impl Into<String>) -> Self {
self.id = Some(id.into());
self
}
pub fn delete(mut self, delete: bool) -> Self {
self.delete = Some(if delete { 1 } else { 0 });
self
}
pub fn ttl(mut self, ttl: i32) -> Self {
self.ttl = Some(ttl);
self
}
pub fn build(self) -> Notification {
Notification {
device_key: self.device_key,
device_keys: self.device_keys,
title: self.title,
subtitle: self.subtitle,
body: self.body,
markdown: self.markdown,
image: self.image,
sound: self.sound,
badge: self.badge,
icon: self.icon,
group: self.group,
url: self.url,
copy: self.copy,
action: self.action,
is_archive: self.is_archive,
is_url_encode: self.is_url_encode,
auto_copy: self.auto_copy,
level: self.level,
volume: self.volume,
call: self.call,
id: self.id,
delete: self.delete,
ttl: self.ttl,
}
}
}