wave-api 0.1.0

Typed Rust client for the Wave Accounting GraphQL API
Documentation
use wave_claw::{OAuthConfig, WaveClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    dotenvy::dotenv().ok();

    let client = WaveClient::with_oauth(OAuthConfig {
        client_id: std::env::var("CLIENT_ID")?,
        client_secret: std::env::var("CLIENT_SECRET")?,
        access_token: std::env::var("TOKEN")?,
        refresh_token: std::env::var("REFRESH_TOKEN")?,
        redirect_uri: std::env::var("REDIRECT_URI")
            .unwrap_or_else(|_| "http://localhost:3099/callback".into()),
        on_token_refresh: None,
    });

    let user = client.get_user().await?;
    println!(
        "Authenticated as: {} ({})",
        user.default_email.as_deref().unwrap_or("?"),
        user.id
    );

    let businesses = client.list_businesses(Default::default()).await?;
    println!("\nBusinesses ({} total):", businesses.total_count.unwrap_or(0));
    for biz in &businesses.items {
        println!(
            "  {}{} [{}]",
            biz.id,
            biz.name,
            biz.currency.code
        );
    }

    Ok(())
}