barkust 0.2.1

A Rust client library and CLI for the Bark push notification service
Documentation
use barkust::{BarkClient, Level, Notification};

#[tokio::main]
async fn main() -> Result<(), barkust::Error> {
    let device_key = std::env::var("BARK_KEY").expect("BARK_KEY environment variable not set");

    let client = BarkClient::new(Some(device_key))?;

    // Simple push.
    let response = client
        .send_simple("Hello from barkust", "This is a simple notification")
        .await?;
    println!("Simple push response: {response:?}");

    // Fully customized push.
    let notification = Notification::builder()
        .title("Custom notification")
        .subtitle("With subtitle")
        .body("Built with the builder API")
        .image("https://day.app/assets/images/avatar.jpg")
        .sound("minuet")
        .group("demo")
        .level(Level::Active)
        .archive(true)
        .build();

    let response = client.send(&notification).await?;
    println!("Custom push response: {response:?}");

    // Batch push.
    let batch = Notification::builder()
        .title("Batch push")
        .body("Sent to multiple devices")
        .build();

    // Replace with your own device keys.
    let keys = vec!["key1".into(), "key2".into()];
    let response = client.send_batch(&batch, keys).await?;
    println!("Batch push response: {response:?}");

    Ok(())
}