use apify_client::ApifyClient;
use chrono::Utc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = std::env::var("APIFY_TOKEN").expect("set APIFY_TOKEN");
let client = ApifyClient::new(token);
let user = client.me().get().await?.expect("current user");
println!("Account id: {}", user.id);
println!("Username: {}", user.username.as_deref().unwrap_or("(none)"));
let usage = client.me().monthly_usage().await?;
if let Some(cycle) = usage.get("usageCycle") {
println!("Current usage cycle: {cycle}");
}
let date = Utc::now().format("%Y-%m-%d").to_string();
let dated_usage = client.me().monthly_usage_for_date(Some(&date)).await?;
if let Some(cycle) = dated_usage.get("usageCycle") {
println!("Usage cycle containing {date}: {cycle}");
}
Ok(())
}