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
println!("fetching activities..."); | |
let activities = fetch_activities(&token).await?; | |
println!("activities: {:?}", activities); |
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(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct ActivitiesResponse { | |
activities: Vec<Activity>, | |
inactive_activities: Vec<Activity>, | |
archived_activities: Vec<Activity>, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] |
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
if !activities.is_empty() { | |
println!("starting to track..."); | |
let tracking = start_tracking(&activities.get(0).expect("exists").id, &token).await?; | |
println!("started tracking: {:?}", tracking); | |
let time_entry = stop_tracking(&token).await?; | |
println!("created time entry: {:?}", time_entry); | |
} |
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, |
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 StopTrackingRequest { | |
stopped_at: String, | |
} | |
#[derive(Deserialize, Debug)] | |
#[serde(rename_all = "camelCase")] | |
struct TimeEntryResponse { | |
created_time_entry: TimeEntry, |
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
println!("creating report..."); | |
generate_report(&token).await?; | |
println!("downloaded report to: {}", REPORT_FILE); |
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
use tokio::fs; | |
async fn generate_report(token: &str) -> Result<(), Error> { | |
let resp = CLIENT | |
.get(&url( | |
"/report/2020-01-01T00:00:00.000/2020-12-31T23:59:59.999?timezone=Europe/Vienna", | |
)) | |
.header("Authorization", auth(token)) | |
.send() | |
.await? |
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
export TMLR_API_KEY=<your api key> | |
export TMLR_API_SECRET=<your api secret> | |
cargo run |
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
[dependencies] | |
reqwest = { version = "0.10", features = ["json"] } | |
tokio = { version = "0.2", features = ["macros", "rt-threaded"] } | |
serde = {version = "1.0", features = ["derive"] } | |
serde_json = "1.0" | |
once_cell = "1.4" | |
warp = "0.2" |
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
lt --port 8000 | |
your url is: https://friendly-mule-3.loca.lt |