Rust client library for the Focusmate API.
examples | ||
src | ||
.gitignore | ||
Cargo.lock | ||
Cargo.toml | ||
LICENSE | ||
README.md |
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