fix switchcounter API

This commit is contained in:
Cadey Ratio 2020-11-19 09:52:37 -05:00
parent 35017cf980
commit 3a428a155d
2 changed files with 17 additions and 1 deletions

View File

@ -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 <webhook-url>");
let cli = SwitchCounter::new(whurl);
let status = cli.status()?;
println!("{:?}", status);
Ok(())
}

View File

@ -24,7 +24,7 @@ pub struct SwitchCommand {
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
pub struct Status { pub struct Status {
pub member_name: String, pub member_name: String,
pub started_at: chrono::NaiveDateTime, pub started_at: String,
} }
pub struct Client { pub struct Client {
@ -55,6 +55,7 @@ impl Client {
let resp = ureq::post(&self.webhook_url).send_json(serde_json::to_value(Wrapper { let resp = ureq::post(&self.webhook_url).send_json(serde_json::to_value(Wrapper {
webhook: FrontAsk::default(), webhook: FrontAsk::default(),
})?); })?);
if resp.ok() { if resp.ok() {
Ok(resp.into_json_deserialize()?) Ok(resp.into_json_deserialize()?)
} else { } else {