zammad-api 0.4.0

Async, idiomatic Rust client for the Zammad Service Platform
Documentation
//! Create a ticket with an initial article.
//!
//! ```sh
//! ZAMMAD_URL=https://help.example.com ZAMMAD_TOKEN=... \
//!   cargo run --example create_ticket
//! ```

use zammad_api::{models::NewArticle, Auth, Client};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let url = std::env::var("ZAMMAD_URL")?;
    let token = std::env::var("ZAMMAD_TOKEN")?;

    let client = Client::builder().url(url).auth(Auth::token(token)).build()?;

    let ticket = client
        .tickets()
        .create()
        .title("Server is on fire")
        .group("Users")
        .customer("customer@example.com")
        .state("new")
        .priority("2 normal")
        .article(
            NewArticle::new("<p>Please send help.</p>")
                .article_type("note")
                .content_type("text/html"),
        )
        .send()
        .await?;

    println!("created ticket #{} ({})", ticket.id, ticket.number.unwrap_or_default());
    Ok(())
}