From 3a428a155df88308509a9850417ce9beb4ea456e Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Thu, 19 Nov 2020 09:52:37 -0500 Subject: [PATCH] fix switchcounter API --- backend/src/bin/switchcounter_read.rs | 15 +++++++++++++++ backend/src/web/switchcounter.rs | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 backend/src/bin/switchcounter_read.rs diff --git a/backend/src/bin/switchcounter_read.rs b/backend/src/bin/switchcounter_read.rs new file mode 100644 index 0000000..18f6bec --- /dev/null +++ b/backend/src/bin/switchcounter_read.rs @@ -0,0 +1,15 @@ +use color_eyre::eyre::Result; +use mi::web::SwitchCounter; +use std::env; + +fn main() -> Result<()> { + let whurl = env::args() + .skip(1) + .next() + .expect("usage: switchcounter_read "); + let cli = SwitchCounter::new(whurl); + let status = cli.status()?; + println!("{:?}", status); + + Ok(()) +} diff --git a/backend/src/web/switchcounter.rs b/backend/src/web/switchcounter.rs index cdd6e7b..1387e61 100644 --- a/backend/src/web/switchcounter.rs +++ b/backend/src/web/switchcounter.rs @@ -24,7 +24,7 @@ pub struct SwitchCommand { #[derive(Deserialize, Debug)] pub struct Status { pub member_name: String, - pub started_at: chrono::NaiveDateTime, + pub started_at: String, } pub struct Client { @@ -55,6 +55,7 @@ impl Client { let resp = ureq::post(&self.webhook_url).send_json(serde_json::to_value(Wrapper { webhook: FrontAsk::default(), })?); + if resp.ok() { Ok(resp.into_json_deserialize()?) } else {