Add: Stamp::new()
This commit is contained in:
parent
900d6ae3f0
commit
40d74ef0bf
@ -15,23 +15,26 @@ pub struct Stamp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Stamp {
|
impl Stamp {
|
||||||
#[tokio::main]
|
pub fn new(config_file: &PathBuf,
|
||||||
pub async fn add(&self, config_file: &PathBuf) -> reqwest::Response {
|
dstart: &str,
|
||||||
|
dend: &str,
|
||||||
|
description: &str,
|
||||||
|
task: u32
|
||||||
|
) -> Stamp {
|
||||||
// Config
|
// Config
|
||||||
let mut default_config = config::Config::default();
|
let mut default_config = config::Config::default();
|
||||||
let config = default_config.parse(&config_file);
|
let config = default_config.parse(&config_file);
|
||||||
|
Stamp {
|
||||||
// Call api
|
id: 0,
|
||||||
let endpoint = format!("{}{}", &config.url, "stamp/add");
|
user_id: config.user_id,
|
||||||
let client = reqwest::Client::new();
|
project_id: 0,
|
||||||
let res = client.post(endpoint)
|
start: Some(dstart.to_string()),
|
||||||
.header("Authorization", &config.key)
|
end: Some(dend.to_string()),
|
||||||
.json(&self)
|
description: Some(description.to_string()),
|
||||||
.send()
|
task_id: Some(task),
|
||||||
.await;
|
|
||||||
|
|
||||||
res.unwrap()
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn stop(&self, config_file: &PathBuf) -> reqwest::Response {
|
pub async fn stop(&self, config_file: &PathBuf) -> reqwest::Response {
|
||||||
// Config
|
// Config
|
||||||
|
Loading…
Reference in New Issue
Block a user