Documentation for 4.0 (pre-release). Using 3.x? See the README on main.
Skip to content

Units (Einheiten) ​

API wrapper for the account's units at /units (e.g. "Stunde", "Stück", "Paletten"). Articles and document items refer to units.

Access ​

php
$billomat->units

Justpilot\Billomat\Api\UnitsApi.

Endpoints ​

MethodHTTPPath
list($filters?)GET/units
listPage($filters?)GET/units
iterateAll($filters?, $pageSize?)GET/units (all pages)
get($id)GET/units/{id}
getOrFail($id)GET/units/{id}

The API is read-only in the SDK. Billomat supports create, update and delete, but the SDK doesn't expose them as methods. If you need them, call $billomat->getHttpClient() directly.

Methods ​

list(array $filters = []): list<Unit> ​

php
foreach ($billomat->units->list() as $unit) {
    printf("#%d %s\n", $unit->id, $unit->name);
}

Filter parameters:

ParameterDescription
nameSubstring match on the name; case-insensitive
page, per_pagePagination — see Pagination and filtering

listPage(array $filters = []): Page<Unit> ​

One page plus PageInfo (page, perPage, total) in $page->info.

iterateAll(array $filters = [], int $pageSize = 100): Generator<Unit> ​

Lazy iteration over all pages.

get(int $id): ?Unit ​

Returns null on 404.

getOrFail(int $id): Unit ​

Like get(), but throws NotFoundException instead of returning null.

Read model: Unit ​

final readonly class Unit.

PropertyBillomat fieldType
ididint
namenamestring
created, updatedcreated, updated?\DateTimeImmutable
customfieldcustomfield?string — free extra field, see Custom meta attributes
extra—array<string,mixed>: fields the SDK doesn't map yet, raw (see Read models)

Pitfalls ​

  • Single-item list quirk. With only one unit in the account Billomat returns an object instead of a list; UnitsApi::list() normalizes this.
  • Deleting fails while in use. Billomat rejects DELETE /units/{id} as long as the unit is still assigned to articles (not relevant for the SDK right now, as there is no delete()).

End-to-end example ​

php
<?php

declare(strict_types=1);

require __DIR__ . '/vendor/autoload.php';

use Justpilot\Billomat\BillomatClient;

$billomat = BillomatClient::create(
    billomatId: 'mycompany',
    apiKey: getenv('BILLOMAT_API_KEY'),
);

// All units
foreach ($billomat->units->iterateAll() as $unit) {
    printf("[#%d] %s\n", $unit->id, $unit->name);
}

// Search by filter
$matches = $billomat->units->list(['name' => 'stunde']);
printf("%d matches for 'stunde'\n", \count($matches));

Unofficial SDK, not affiliated with Billomat GmbH. Released under the Apache License 2.0.