Skip to content
nejcc edited this page Jul 7, 2026 · 1 revision

Usage

Everything goes through the Minimax facade. Resources are org-scoped and return plain arrays using Minimax's own field names.

The manager

Minimax carries the current organisation context and hands you resource objects.

Method Returns Notes
forOrg($orgId) Minimax Immutable clone scoped to a different org.
orgs() Orgs Not org-scoped.
customers() items() orders() resource Org-scoped CRUD.
invoices() Invoices CRUD + issue/pdf actions — see Invoices.
vatRates() currencies() countries() reportTemplates() resource Code lists.
resource($slug) Generic Any endpoint by slug.
client() Client The low-level HTTP client.

Org-scoped resources throw MinimaxException if no org is set. Configure MINIMAX_ORG_ID or call forOrg($id) first.

CRUD

Every org-scoped resource shares the same base surface:

Method HTTP Description
all($query = []) GET List records.
find($id) GET Fetch one record by id.
byCode($code, $query = []) GET Fetch one record by its business code.
create($data) POST Create; follows the Location header and returns the created entity.
update($id, $data) PUT Replace a record.
delete($id) DELETE Delete a record.
$rows     = Minimax::customers()->all(['PageSize' => 50])['Rows'];
$customer = Minimax::customers()->find(1);
$created  = Minimax::customers()->create(['Name' => 'ACME d.o.o.']);
Minimax::customers()->update($created['CustomerId'], ['Name' => 'ACME Ltd']);
Minimax::customers()->delete($created['CustomerId']);

create() follows the 201 Created Location header, so it returns the full record including its RowVersion.

Organisations

orgs() is the only resource that isn't org-scoped. Use it to discover your MINIMAX_ORG_ID.

foreach (Minimax::orgs()->all()['Rows'] as $row) {
    $row['Organisation']['ID'];   // e.g. 123456
    $row['Organisation']['Name']; // e.g. "Demo d.o.o."
}

Code lists

vatRates(), currencies(), countries() and reportTemplates() are read-oriented code lists. byCode() resolves a record by its business code.

$vat = Minimax::vatRates()->byCode('S');   // ['VatRateId' => 1, 'Percent' => 22, ...]
$eur = Minimax::currencies()->byCode('EUR');
$si  = Minimax::countries()->byCode('SI');

Generic resources

resource($slug) binds the CRUD surface to any org-scoped endpoint at runtime — no dedicated class needed.

Minimax::resource('journals')->all();
Minimax::resource('accounts')->find(1);

Error handling

Any failed request throws Nejcc\Minimax\MinimaxException, carrying the HTTP status and the decoded response body.

use Nejcc\Minimax\MinimaxException;

try {
    $customer = Minimax::customers()->find(999999);
} catch (MinimaxException $e) {
    $e->getCode();  // HTTP status, e.g. 404
    $e->body;       // decoded response body
}

Clone this wiki locally