withone 0.1.0

Typed Rust client for the One API: the client, webhooks and the action type every withone-<platform> crate builds on.
Documentation
use one::{Method, One, Operation};

/// Minimal runnable example: issue one passthrough call and print the response.
///
/// Usage:
///   cargo run -p withone --example call -- <secret> <connection_key>
/// <system_id> <method> <path> [body]
///
/// Example:
///   cargo run -p withone --example call -- sk_live_xxx live::gmail::abc
/// 64f0... GET /users/me
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut args = std::env::args().skip(1);
    let secret = args.next().expect("arg 1: secret");
    let connection_key = args.next().expect("arg 2: connection_key");
    let system_id = args.next().expect("arg 3: system_id");
    let method: Method = args.next().expect("arg 4: method").parse().expect("valid HTTP method");
    let path = args.next().expect("arg 5: path");
    let body = args.next().unwrap_or_default();

    let one = One::new(secret);

    let response = one
        .connection(connection_key)
        .run(Operation::action(system_id, method, path).raw_body(body))
        .await?;

    println!("status: {}", response.status());
    println!("{}", response.text());
    Ok(())
}