brawl-rs 0.1.0

A Rust wrapper for the Brawl Stars API
Documentation
// Example: Fetch Game Events
// To run: cargo run --example events

use brawl_rs::prelude::*;
use std::env::var;

#[tokio::main]
#[cfg(feature = "events")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = BrawlClient::new(var("BRAWL_TOKEN")?);

    // Fetch game modes
    match GameModes::get(&client).await {
        Ok(modes) => {
            println!("=== Available Game Modes ({} total) ===", modes.items.len());
            for mode in modes.items.iter().take(10) {
                println!(
                    "ID: {} - {}",
                    mode.id,
                    mode.name.as_deref().unwrap_or("Unknown")
                );
            }
        }
        Err(e) => eprintln!("Error fetching game modes: {}", e),
    }

    println!();

    // Fetch current event rotation
    match Rotation::get(&client).await {
        Ok(rotations) => {
            for rotation in rotations {
                println!("=== Current Event Rotation ===");
                println!("Event Mode: {}", rotation.event.mode);
                println!("Map: {}", rotation.event.map);
                println!("Start Time: {}", rotation.start_time);
                println!("End Time: {}", rotation.end_time);
                println!(
                    "Duration: {} minutes",
                    (rotation.end_time - rotation.start_time).num_minutes()
                );
            }
        }
        Err(e) => eprintln!("Error fetching rotation: {:?}", e),
    }

    Ok(())
}