Skip to content

Instantly share code, notes, and snippets.

@zupzup
Created October 29, 2020 13:37
Show Gist options
  • Save zupzup/bab2fdb5ec04cc3ba89927fd4b234907 to your computer and use it in GitHub Desktop.
Save zupzup/bab2fdb5ec04cc3ba89927fd4b234907 to your computer and use it in GitHub Desktop.
Timeular Public API stop tracking
#[derive(Serialize, Debug)]
#[serde(rename_all = "camelCase")]
struct StopTrackingRequest {
stopped_at: String,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct TimeEntryResponse {
created_time_entry: TimeEntry,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct TimeEntry {
id: String,
activity_id: String,
duration: Duration,
note: Note,
}
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
struct Duration {
started_at: String,
stopped_at: String,
}
async fn stop_tracking(token: &str) -> Result<TimeEntry, Error> {
let body = StopTrackingRequest {
stopped_at: "2020-08-03T05:00:00.000".to_string(),
};
let resp = CLIENT
.post(&url("/tracking/stop"))
.header("Authorization", auth(token))
.json(&body)
.send()
.await?
.json::<TimeEntryResponse>()
.await?;
Ok(resp.created_time_entry)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment