From 40eb9cb5af25d786aa597e8b74f279846971460c Mon Sep 17 00:00:00 2001 From: isaaguilar Date: Mon, 2 Oct 2023 14:01:08 -0400 Subject: [PATCH] debug reposne json --- src/poll.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/poll.rs b/src/poll.rs index 6921a2d..390413d 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -21,7 +21,7 @@ impl Response { if self.data.len() == 0 { return true; } - if self.data[0].status != "approved" && self.data[0].status != "canceled" { + if self.data[0].status != "complete" { return true; } false @@ -31,7 +31,7 @@ impl Response { if self.is_nodata() { return false; } - self.data[0].status == "approved" + self.data[0].is_approved } } @@ -44,6 +44,7 @@ struct StatusInfo { #[derive(Debug, Deserialize)] struct DataItem { status: String, + is_approved: bool, } #[derive(Debug)] @@ -80,6 +81,7 @@ impl APIClient { /// Return int where: 0=false, 1=true and anything else is nodata fn response_check(resp: String) -> i8 { let r: Response = serde_json::from_str(resp.as_str()).unwrap_or(Response::default()); + println!("{:?}", r); if r.is_unauthorized() { println!("The request was unauthorized"); exit(1); @@ -115,7 +117,9 @@ pub fn poll() { ); loop { let response = client.query_approval().unwrap_or(String::from("")); + let status = response_check(response); + match status { 0 => { println!("Canceled via database");