hackerone-api 0.2.0

Unofficial, dependency-light Rust client for the HackerOne API (v1): submit reports, read your reports, hacktivity, balance, and earnings.
Documentation
//! List programs and the newest reports for the authenticated user.
//!
//! ```sh
//! export HACKERONE_API_IDENTIFIER=...
//! export HACKERONE_API_TOKEN=...
//! cargo run --example list_reports
//! ```

use hackerone_api::{Client, ReportQuery};

fn main() -> Result<(), hackerone_api::Error> {
    let identifier = std::env::var("HACKERONE_API_IDENTIFIER")
        .expect("set HACKERONE_API_IDENTIFIER (token identifier)");
    let token = std::env::var("HACKERONE_API_TOKEN").expect("set HACKERONE_API_TOKEN");

    let client = Client::new(identifier, token);

    let me = client.me()?;
    println!(
        "authenticated as {} <{}>",
        me.username.as_deref().unwrap_or("?"),
        me.email.as_deref().unwrap_or("?")
    );

    println!("\nprograms:");
    for program in client.programs()?.items() {
        println!(
            "  {:<24} {:<12} bounties={}",
            program.handle.as_deref().unwrap_or("?"),
            program.state.as_deref().unwrap_or("?"),
            program.offers_bounties.unwrap_or(false),
        );
    }

    println!("\nnewest reports:");
    let page = client.reports(&ReportQuery::new().sort("-created_at").page(1, 10))?;
    for (id, report) in page.ids().zip(page.items()) {
        println!(
            "  {:<10} {:<10} {}",
            id.unwrap_or(""),
            report.state.as_deref().unwrap_or("?"),
            report.title.as_deref().unwrap_or("(untitled)"),
        );
    }

    Ok(())
}