pub mod input;
pub mod ui;
pub use input::handle_triggers_input;
pub use ui::draw_triggers;
#[derive(Clone, Copy, Debug)]
pub enum TriggerEvent {
DayStart,
OooStart,
OooEnd,
}
pub const EVENT_LABELS: [&str; 3] = [
"Day Start",
"Out of Office Start",
"Out of Office End",
];
impl TriggerEvent {
pub fn index(self) -> usize {
match self {
TriggerEvent::DayStart => 0,
TriggerEvent::OooStart => 1,
TriggerEvent::OooEnd => 2,
}
}
pub fn label(self) -> &'static str {
EVENT_LABELS[self.index()]
}
}
pub fn send(url: &str, body: &str) -> Result<u16, String> {
let client = reqwest::blocking::Client::new();
let resp = client
.post(url)
.header("Content-Type", "application/json")
.body(body.to_string())
.send()
.map_err(|e| e.to_string())?;
Ok(resp.status().as_u16())
}