package bizowie-api

  1. Overview
  2. Docs

bizowie-api (OCaml)

OCaml client for the Bizowie ERP API. Port of the Perl module WWW::Bizowie::API.

  • Minimum OCaml: 4.14
  • Built on cohttp-lwt-unix, lwt, yojson
  • Supports both v1 (multipart) and v2 (JSON) endpoints
  • Both Lwt and blocking interfaces

Install

opam install bizowie-api

Usage

Blocking

let bz =
  Bizowie_api.create
    ~api_key:"02cc7058-cd22-4c8e-ad7c-a8f3f2a64bd0"
    ~secret_key:"58c57abc-1e16-3571-bb35-73876bcef746"
    ~site:"mysite.bizowie.com"
    ()
in
let resp =
  Bizowie_api.call_sync bz
    "databases/add_note/3/10/123"
    (`Assoc [("comment", `String "I added this comment via the API!")])
in
if resp.success then
  print_endline (Yojson.Safe.pretty_to_string resp.data)

Lwt

open Lwt.Infix

let main =
  let bz =
    Bizowie_api.create
      ~api_key:"..." ~secret_key:"..." ~site:"mysite.bizowie.com" ()
  in
  Bizowie_api.call bz "things/list" (`Assoc [])
  >|= fun resp ->
  if resp.success then print_endline (Yojson.Safe.to_string resp.data)

let () = Lwt_main.run main

v2 endpoint

let bz =
  Bizowie_api.create
    ~api_key:"..." ~secret_key:"..." ~site:"mysite.bizowie.com"
    ~v2:true
    ()

Options

Argument

Default

Description

~api_key

required

Bizowie API key.

~secret_key

required

Bizowie secret key.

~site

required

Hostname of your Bizowie instance.

?v2

false

Use the v2 API endpoint.

?api_version

"1.00"

API version sent with v2 requests.

?debug

false

Print raw response to stderr on JSON decode fail.

?transport

default_transport

Override the HTTP transport (useful for tests).

Responses

type response = {
  data : Yojson.Safe.t;   (* response body, success field stripped *)
  success : bool;          (* extracted from the success field *)
}

If the body isn't parseable as JSON, data is `Assoc [("unprocessed", `Int 1)] and success is false.

Build / Test

opam install . --deps-only --with-test
dune build
dune runtest

Publishing to opam-repository

opam packages live in the ocaml/opam-repository GitHub repo. Easiest tooling: opam-publish.

One-time setup

opam install opam-publish

Release flow

  1. Tag the release in git and push the tag:

       git tag -a v0.5.0 -m "0.5.0"
    git push origin v0.5.0
  2. Create a GitHub release for the tag (so opam-publish can find the tarball).
  3. Run:

    opam publish https://github.com/mjflick/bizowie-api-ocaml/releases/download/v0.5.0/bizowie-api-0.5.0.tar.gz

    opam-publish will:

    • download the tarball, compute its SHA256,
    • generate packages/bizowie-api/bizowie-api.0.5.0/opam,
    • fork ocaml/opam-repository on your behalf,
    • open a pull request.
  4. A maintainer will run the package through opam-ci (build matrix across OCaml versions and platforms) and merge once green. Typical turnaround: a few hours to a couple of days.

Manual alternative

If you prefer to do it by hand:

  1. Fork ocaml/opam-repository.
  2. Create packages/bizowie-api/bizowie-api.0.5.0/opam — copy from the bizowie-api.opam in the source tree and add a url stanza:

       url {
      src: "https://github.com/mjflick/bizowie-api-ocaml/archive/refs/tags/v0.5.0.tar.gz"
      checksum: "sha256=PUT_SHA256_HERE"
    }

    You can compute the checksum with:

    curl -sL <URL> | sha256sum
  3. Open a PR against ocaml/opam-repository.

License

Dual-licensed under the Artistic License 1.0 (Perl) or GPL 1.0 or later, matching the original Perl module's "same terms as Perl itself" clause.