Skip to content

Commit

Permalink
debug reposne json
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaguilar committed Oct 2, 2023
1 parent 4b40ba8 commit 40eb9cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +31,7 @@ impl Response {
if self.is_nodata() {
return false;
}
self.data[0].status == "approved"
self.data[0].is_approved
}
}

Expand All @@ -44,6 +44,7 @@ struct StatusInfo {
#[derive(Debug, Deserialize)]
struct DataItem {
status: String,
is_approved: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 40eb9cb

Please sign in to comment.