PHP: >= 7.4
Extensions: Composer, PHP-JSON
composer:
composer require clicksports/lex-office-api
Search for the official API Documentation here.
You need an API Key for that.
$apiKey = getenv('LEX_OFFICE_API_KEY'); // store keys in .env file
$api = new \Clicksports\LexOffice\Api($apiKey);
// can be any PSR-6 compatibly cache handler
// in this example we are using symfony/cache
$cacheInterface = new \Symfony\Component\Cache\Adapter\FilesystemAdapter(
'lexoffice',
3600,
__DIR__ . '/cache'
);
$api->setCacheInterface($cacheInterface);
// get a page
/** @var \Clicksports\LexOffice\Api $api */
$client = $api->contact();
$client->size = 100;
$client->sortDirection = 'ASC';
$client->sortProperty = 'name';
// get a page
$response = $client->getPage(0);
//get all
$response = $client->getAll();
// other methods
$response = $client->get($entityId);
$response = $client->create($data);
$response = $client->update($entityId, $data);
$response = $api->invoice()->getAll();
$response = $api->invoice()->get($entityId);
$response = $api->invoice()->create($data);
$response = $api->orderConfirmation()->getAll();
$response = $api->orderConfirmation()->get($entityId);
$response = $api->orderConfirmation()->create($data);
$response = $api->quotation()->getAll();
$response = $api->quotation()->get($entityId);
$response = $api->quotation()->create($data);
$response = $api->voucher()->getAll();
$response = $api->voucher()->get($entityId);
$response = $api->voucher()->create($data);
$response = $api->voucher()->update($entityId, $data);
$client = $api->voucherlist();
$client->size = 100;
$client->sortDirection = 'DESC';
$client->sortColumn = 'voucherNumber';
$client->types = [
'salesinvoice',
'salescreditnote',
'purchaseinvoice',
'purchasecreditnote',
'invoice',
'creditnote',
'orderconfirmation',
'quotation'
];
$client->statuses = [
'draft',
'open',
'paid',
'paidoff',
'voided',
//'overdue', overdue can only be fetched alone
'accepted',
'rejected'
];
// get everything what we can, not recommend:
//$client->setToEverything()
// get a page
$response = $client->getPage(0);
//get all
$response = $client->getAll();
$json = $api->voucher()->getAsJson($response);