Created
October 29, 2020 13:37
-
-
Save zupzup/eb0313e0f5ba5b3daea77b03b02a7178 to your computer and use it in GitHub Desktop.
Timeular Public API start tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Serialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct TrackingRequest { | |
started_at: String, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct TrackingResponse { | |
current_tracking: Tracking, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct Tracking { | |
id: i64, | |
activity_id: String, | |
started_at: String, | |
note: Note, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct Note { | |
text: Option<String>, | |
tags: Vec<TagOrMention>, | |
mentions: Vec<TagOrMention>, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct TagOrMention { | |
id: i64, | |
key: String, | |
label: String, | |
scope: String, | |
space_id: String, | |
} | |
async fn start_tracking(activity_id: &str, token: &str) -> Result<Tracking, Error> { | |
let body = TrackingRequest { | |
started_at: "2020-08-03T04:00:00.000".to_string(), | |
}; | |
let resp = CLIENT | |
.post(&url(&format!("/tracking/{}/start", activity_id))) | |
.header("Authorization", auth(token)) | |
.json(&body) | |
.send() | |
.await? | |
.json::<TrackingResponse>() | |
.await?; | |
Ok(resp.current_tracking) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment