Skip to main content

Crate koban

Crate koban 

Source
Expand description

koban is a client library for the Invoice Ninja API, built for humans and AI agents.

The library exposes an ApiClient for talking to an Invoice Ninja instance, a Config for environment-first credential handling, the Resource catalogue of API resource families, typed models for the common resources, and a redaction helper for keeping tokens out of logs and errors.

Typed access via the resource accessors and models:

use koban::{ApiClient, Config};

let client = ApiClient::new(Config::from_env()?);
let invoices = client.invoices().list().await?;
for invoice in &invoices {
    println!("{} -> {}", invoice.number, invoice.balance);
}

The raw JSON methods (ApiClient::get_json and friends) remain available as a low-level escape hatch for endpoints or fields the typed layer does not model.

Token handling is environment-first via INVOICE_NINJA_API_TOKEN and the optional INVOICE_NINJA_BASE_URL. Enable the miette feature to attach diagnostic help text to KobanError.

Re-exports§

pub use models::Client;
pub use models::Contact;
pub use models::Credit;
pub use models::Data;
pub use models::Expense;
pub use models::Invoice;
pub use models::InvoiceItem;
pub use models::Meta;
pub use models::Paginated;
pub use models::Pagination;
pub use models::Payment;
pub use models::Product;
pub use models::Project;
pub use models::Quote;
pub use models::Task;
pub use models::Vendor;

Modules§

models
Typed domain models for Invoice Ninja resources.

Structs§

ApiClient
Config
Resources
A typed handle to a single Invoice Ninja resource family.

Enums§

KobanError
Errors returned by the koban library.
Resource

Constants§

API_TOKEN_ENV
BASE_URL_ENV
DEFAULT_BASE_URL

Functions§

redact

Type Aliases§

Result
Convenience alias for results returned by the koban library.