ocolin/billmaxapi

Basic PHP Rest Client for Billmax API

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ocolin/billmaxapi

1.1 2025-11-12 19:08 UTC

This package is auto-updated.

Last update: 2025-11-12 19:09:28 UTC


README

A small PHP REST client for the Billmax REST API.

Future updates

Right now this client does not handle user logins. That will be added in next version.

Instantiation

First we must create a client. It will require knowing the URL of the Billmax server as well as the API key for the server. The API key is the session ID of the Billmax remote application for the REST service.

Constructor parameters:

  • base_uri - (env) The URL of the API server, the root of the end points.
  • api_key - (env) Billmax server API key from Remote Application.
  • timeout - (optional) Set the HTTP timeout as needed. Defaults to 20 seconds.
  • verify - (optional) Verify SSL credentials. Defaults to off.
  • errors - (optional) Display HTTP errors. Default is off.

Environment variables

Instead of using constructor arguments, environment variables can be used for the base URL and API key.

  • BILLMAX_API_URL
  • BILLMAX_API_KEY

Example - Environment variables

$_ENV['BILLMAX_API_URL'] = 'https://server.com:3100/api/billmaxCoreApi/v1/';
$_ENV['BILLMAX_API_KEY'] = 'ABCDEFG';

$client = new Ocolin\BillmaxAPI\Client();

Example - Environment with optional parameters

$_ENV['BILLMAX_API_URL'] = 'https://server.com:3100/api/billmaxCoreApi/v1/';
$_ENV['BILLMAX_API_KEY'] = 'ABCDEFG';

$client = new Ocolin\BillmaxAPI\Client(
    timeout: 100,
     verify: true,
     errors: true
);

Example - Using constructor arguments

$client = new Ocolin\BillmaxAPI\Client(
    base_uri: 'https://server.com:3100/api/billmaxCoreApi/v1/',
    api_key: 'ABCDEFG'
);

Making an API call

Swagger reference

https://demo5debian.billmax.com:3105/api/billmaxCoreApi/v1/api-docs/#/

Call Parameters

  • path - The endpoint path, which can be copy/pasted from the swagger API docs. This includes the curly brace variables.
  • method - The HTTP methods from the API docs. Defaults to GET.
  • query - Array or object with the parameters and values to be used in the path as well as the URI. Any path parameters in curly braces will be replaced with a value from this array/object.
  • body - Parameters for the HTTP body. Used for POST and PATCH methods.

Example GET

$output = $client->call(
    path: '/accounts/{id}'
    query: [ 'id' => '1' ]
);

Example POST

$output = $client->call(
    path: '/pops/',
    method: 'POST',
    query: [
        'name' => 'My new POP',
        'virtualCompany' => 'My Company'
    ]
);

Example PATCH

$output = self::$api->call(
    path: '/pops/{id}',
    method: 'PATCH',
    query: [ 'id' => 1 ],
    body: [
        'name' => 'Updated POP name',
        'generation' => '2025-11-11 00:00:00'
    ]
);