Add: Stamp stop feature
This commit is contained in:
parent
8a3a4520eb
commit
ce2a0d2cbe
17
src/main.rs
17
src/main.rs
@ -130,6 +130,23 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if stop == 1 {
|
||||||
|
console::info("Stop last stamp");
|
||||||
|
let stamp = Stamp {
|
||||||
|
id: 0,
|
||||||
|
user_id: 0,
|
||||||
|
project_id: 0,
|
||||||
|
start: Some("".to_string()),
|
||||||
|
end: Some("".to_string()),
|
||||||
|
description: Some("".to_string()),
|
||||||
|
task_id: Some(0),
|
||||||
|
};
|
||||||
|
let stopped = stamp.stop(&config_file);
|
||||||
|
match stopped.status() {
|
||||||
|
reqwest::StatusCode::OK => println!("OK"),
|
||||||
|
other => println!("KO: {:?}, something happened", other),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => console::error("Whut!!!"),
|
_ => console::error("Whut!!!"),
|
||||||
|
@ -32,6 +32,23 @@ impl Stamp {
|
|||||||
|
|
||||||
res.unwrap()
|
res.unwrap()
|
||||||
}
|
}
|
||||||
|
#[tokio::main]
|
||||||
|
pub async fn stop(&self, config_file: &PathBuf) -> reqwest::Response {
|
||||||
|
// Config
|
||||||
|
let mut default_config = config::Config::default();
|
||||||
|
let config = default_config.parse(&config_file);
|
||||||
|
|
||||||
|
// Call api
|
||||||
|
let endpoint = format!("{}{}", &config.url, "stamp/stop");
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let res = client.post(endpoint)
|
||||||
|
.header("Authorization", &config.key)
|
||||||
|
.json(&self)
|
||||||
|
.send()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
res.unwrap()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
Loading…
Reference in New Issue
Block a user