use serde::{Deserialize, Serialize};
#[serde_with::skip_serializing_none]
#[derive(Debug, Serialize, Default)]
pub struct BarkMessage {
title: Option<String>,
subtitle: Option<String>,
body: Option<String>,
device_key: Option<String>,
device_keys: Option<Vec<String>>,
level: Option<String>,
volume: Option<u8>,
badge: Option<u32>,
call: Option<String>,
auto_copy: Option<String>,
copy: Option<String>,
sound: Option<String>,
icon: Option<String>,
group: Option<String>,
ciphertext: Option<String>,
is_archive: Option<String>,
url: Option<String>,
action: Option<String>,
id: Option<String>,
delete: Option<String>,
}
impl BarkMessage {
pub fn new() -> Self {
Self::default()
}
pub fn title(mut self, v: impl Into<String>) -> Self {
self.title = Some(v.into());
self
}
pub fn subtitle(mut self, v: impl Into<String>) -> Self {
self.subtitle = Some(v.into());
self
}
pub fn body(mut self, v: impl Into<String>) -> Self {
self.body = Some(v.into());
self
}
pub fn device_key(mut self, v: impl Into<String>) -> Self {
self.device_key = Some(v.into());
self
}
pub fn device_keys(mut self, v: Vec<String>) -> Self {
self.device_keys = Some(v);
self
}
pub fn level(mut self, v: Level) -> Self {
self.level = Some(v.as_str().to_string());
self
}
pub fn volume(mut self, v: u8) -> Self {
self.volume = Some(v);
self
}
pub fn badge(mut self, v: u32) -> Self {
self.badge = Some(v);
self
}
pub fn call(mut self, v: impl Into<String>) -> Self {
self.call = Some(v.into());
self
}
pub fn auto_copy(mut self, v: impl Into<String>) -> Self {
self.auto_copy = Some(v.into());
self
}
pub fn copy(mut self, v: impl Into<String>) -> Self {
self.copy = Some(v.into());
self
}
pub fn sound(mut self, v: impl Into<String>) -> Self {
self.sound = Some(v.into());
self
}
pub fn icon(mut self, v: impl Into<String>) -> Self {
self.icon = Some(v.into());
self
}
pub fn group(mut self, v: impl Into<String>) -> Self {
self.group = Some(v.into());
self
}
pub fn ciphertext(mut self, v: impl Into<String>) -> Self {
self.ciphertext = Some(v.into());
self
}
pub fn is_archive(mut self, v: impl Into<String>) -> Self {
self.is_archive = Some(v.into());
self
}
pub fn url(mut self, v: impl Into<String>) -> Self {
self.url = Some(v.into());
self
}
pub fn action(mut self, v: impl Into<String>) -> Self {
self.action = Some(v.into());
self
}
pub fn id(mut self, v: impl Into<String>) -> Self {
self.id = Some(v.into());
self
}
pub fn delete(mut self, v: impl Into<String>) -> Self {
self.delete = Some(v.into());
self
}
}
#[derive(Debug, Clone, PartialEq)]
pub enum Level {
Critical,
Active,
TimeSensitive,
Passive,
}
impl Level {
pub(crate) fn as_str(&self) -> &'static str {
match self {
Level::Critical => "critical",
Level::Active => "active",
Level::TimeSensitive => "timeSensitive",
Level::Passive => "passive",
}
}
}
#[derive(Debug, Deserialize)]
pub struct BarkResponse {
pub code: i32,
pub message: String,
pub timestamp: Option<i64>,
}