bizowie-api 0.5.0

Async Rust client for Bizowie's ERP API.
Documentation

bizowie-api (Rust)

Async Rust client for Bizowie's ERP API. Port of the Perl WWW::Bizowie::API module.

  • Async, built on reqwest with rustls
  • Supports both the v1 and v2 API endpoints
  • Two runtime dependencies: reqwest and serde_json

Requirements

  • Rust 1.70 or newer
  • A Tokio runtime (any flavor)

Install

[dependencies]
bizowie-api = "0.5"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde_json = "1"

Quick start

use bizowie_api::BizowieAPI;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let bz = BizowieAPI::new(
        "02cc7058-cd22-4c8e-ad7c-a8f3f2a64bd0",
        "58c57abc-1e16-3571-bb35-73876bcef746",
        "mysite.bizowie.com",
    )
    .v2(true); // recommended for new integrations

    let res = bz
        .call(
            "databases/add_note/3/10/123",
            Some(&json!({ "comment": "hello from Rust" })),
        )
        .await?;

    if res.success == 1 {
        println!("ok: {}", res.data);
    } else {
        eprintln!("failed: {}", res.data);
    }
    Ok(())
}

API

BizowieAPI::new(api_key, secret_key, site)

Creates a client with the required credentials. All three arguments accept anything that implements Into<String> (e.g., &str or String).

Optional builder methods:

Method Description
.v2(bool) Route calls through the v2 endpoint (/bz/apiv2/call/).
.api_version("1.00") API version sent with each v2 request. Defaults to "1.00" when unset.
.debug(bool) Log the raw HTTP body to stderr when the response can't be parsed as JSON.

async fn call(&self, method: &str, params: Option<&Value>) -> Result<BizowieAPIResponse, Error>

Makes an API call.

  • method — path to the API method (everything after /bz/api/ for v1 or /bz/apiv2/call/ for v2). Returns Error::MissingMethod if empty.
  • params — optional &serde_json::Value of parameters. In v2 mode, api_key / secret_key / api_version are injected automatically — don't include them.

BizowieAPIResponse

pub struct BizowieAPIResponse {
    pub data: serde_json::Value,
    pub success: i64,
}
  • success1 on success, 0 otherwise. Pulled from the response body's success field.
  • data — decoded JSON response (with success removed). On a non-JSON response this is { "unprocessed": 1 }.

Error

pub enum Error {
    Http(reqwest::Error),
    MissingMethod,
}

call does not return an error for HTTP-level failures (4xx/5xx). Those are surfaced via success: 0 and whatever the server returned in data. Only network-level failures (DNS, connection refused, TLS) become Error::Http.

v1 vs v2

Aspect v1 (default) v2 (.v2(true))
Endpoint https://{site}/bz/api/{method} https://{site}/bz/apiv2/call/{method}
Auth Sent as separate multipart form fields Injected into the JSON request body
Body multipart/form-data with a request JSON field Raw JSON body with Content-Type: form-data
api_version not sent sent (defaults to "1.00")

v2 is recommended for new integrations.

TLS

Uses rustls (no system OpenSSL needed). Verification is on by default. For self-signed dev hosts, install the cert into your trust store rather than disabling verification.

License

Dual-licensed under the Artistic License 1.0 or the GPL 1.0+, matching the original Perl module.