Skip to content

Exbil/lexoffice-php-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’Ύ Lexoffice PHP API

visitors

Getting Started

Requirements

βš’οΈ Install

In the root of your project execute the following:

composer require exbil/lexoffice-php-api

or add this to your composer.json file:

{
  "require": {
    "exbil/lexoffice-php-api": "^0.14.1"
  }
}

πŸ“‘ Usage

Search for the official API Documentation here.
You need an API Key for that.

πŸ—ƒοΈ Basic

$apiKey = getenv('LEX_OFFICE_API_KEY'); // store keys in .env file
$api = new \exbil\LexOffice\LexOfficeClient($apiKey);

πŸ—ƒοΈ set cache

// 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);

πŸ”š Contact Endpoint

// get a page
/** @var \exbil\LexOffice\LexOfficeClient $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);

πŸ—ΊοΈ Country Endpoint

$response = $api->country()->getAll();

πŸ”š Invoices Endpoint

$response = $api->invoice()->getAll();
$response = $api->invoice()->get($entityId);
$response = $api->invoice()->create($data);
$response = $api->invoice()->document($entityId); // get document ID
$response = $api->invoice()->document($entityId, true); // get file content

πŸ”š Down Payment Invoices Endpoint

$response = $api->downPaymentInvoice()->getAll();
$response = $api->downPaymentInvoice()->get($entityId);
$response = $api->downPaymentInvoice()->create($data);
$response = $api->downPaymentInvoice()->document($entityId); // get document ID
$response = $api->downPaymentInvoice()->document($entityId, true); // get file content

πŸ’΅ Order Confirmation Endpoint

$response = $api->orderConfirmation()->getAll();
$response = $api->orderConfirmation()->get($entityId);
$response = $api->orderConfirmation()->create($data);
$response = $api->orderConfirmation()->document($entityId); // get document ID
$response = $api->orderConfirmation()->document($entityId, true); // get file content

πŸ“ƒ Quotation Endpoint

$response = $api->quotation()->getAll();
$response = $api->quotation()->get($entityId);
$response = $api->quotation()->create($data);
$response = $api->quotation()->document($entityId); // get document ID
$response = $api->quotation()->document($entityId, true); // get file content

πŸ“„ Voucher Endpoint

$response = $api->voucher()->getAll();
$response = $api->voucher()->get($entityId);
$response = $api->voucher()->create($data);
$response = $api->voucher()->update($entityId, $data);
$response = $api->voucher()->document($entityId); // get document ID
$response = $api->voucher()->document($entityId, true); // get file content

πŸ’΅ Credit Notes Endpoint

$response = $api->creditNote()->getAll();
$response = $api->creditNote()->get($entityId);
$response = $api->creditNote()->create($data);
$response = $api->creditNote()->document($entityId); // get document ID
$response = $api->creditNote()->document($entityId, true); // get file content

πŸ’΅ Payment Endpoint

$response = $api->payment()->get($entityId);

πŸ’΅ Payment Conditions Endpoint

$response = $api->paymentCondition()->getAll();

πŸ—‚οΈ Posting Categories Endpoint

$response = $api->postingCategory()->getAll();

πŸ§‘πŸ» Profile Endpoint

$response = $api->profile()->get();

πŸ“œ Recurring Templates Endpoint

// get single entitiy
$response = $api->recurringTemplate()->get($entityId);

// use pagination
$client = $api->recurringTemplate();
$client->size = 100;


// get a page
$response = $client->getPage(0);

//get all
$response = $client->getAll();

πŸ”š Voucherlist Endpoint

$client = $api->voucherlist();

$client->size = 100;
$client->sortDirection = 'DESC';
$client->sortColumn = 'voucherNumber';
$client->types = [
    'salesinvoice',
    'salescreditnote',
    'purchaseinvoice',
    'purchasecreditnote',
    'invoice',
    'downpaymentinvoice',
    '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();

πŸ“ File Endpoint

$response = $api->file()->upload($filePath, $voucherType);
$response = $api->file()->get($entityId);

βš’οΈ Get JSON from Response

$json = $api->*()->getAsJson($response);