Rust client library for the Focusmate API.
Go to file
2024-12-16 21:12:03 -05:00
examples first commit 2024-12-14 11:34:56 -05:00
src first commit 2024-12-14 11:34:56 -05:00
.gitignore first commit 2024-12-14 11:34:56 -05:00
Cargo.lock first commit 2024-12-14 11:34:56 -05:00
Cargo.toml first commit 2024-12-14 11:34:56 -05:00
LICENSE Initial commit 2024-12-16 21:06:14 -05:00
README.md first commit 2024-12-14 11:34:56 -05:00

focusmate-rs

Rust client library for the Focusmate API.

Installation

Add to your Cargo.toml:

[dependencies]
focusmate-rs = "0.1.0"

Usage

use focusmate::FocusmateClient;
use time::OffsetDateTime;

#[tokio::main]
async fn main() {
    let client = FocusmateClient::new("your-api-key".to_string());

    // Get profile
    match client.get_me().await {
        Ok(user) => println!("{user:#?}"),
        Err(e) => println!("Error: {e:?}"),
    }

    // Get public profile of a user
    match client
        .get_user("6c267455-a530-4d4c-ba17-2e375932d976")
        .await
    {
        Ok(user) => println!("{user:#?}"),
        Err(e) => println!("Error: {e:?}"),
    }

    // Get sessions for last month
    let start = OffsetDateTime::now_utc() - time::Duration::days(30);
    let end = OffsetDateTime::now_utc();
    let sessions = client.get_sessions(&start, &end).await;
    match sessions {
        Ok(sessions) => {
            let n_sessions = sessions.iter().filter(|s| s.completed()).count();
            println!("{n_sessions} completed sessions in period.");
        }
        Err(e) => println!("Error: {e:?}"),
    }
}

Features

  • User profile lookup
  • Session history with automatic year-chunking for long date ranges
  • Session partner lookup

License

MIT