88
99## Requirements
1010
11- PHP: >= 8.1
12- Extensions:
11+ PHP: >= 8.1
12+ Extensions:
1313- [ Composer] ( https://getcomposer.org/ )
1414- [ PHP-JSON] ( https://www.php.net/manual/en/book.json.php )
1515- [ PSR-18 HTTP-Client] ( https://packagist.org/providers/psr/http-client-implementation )
1616
1717## Install
1818
19- composer:
19+ composer:
2020` composer require sysix/lex-office-api `
2121
2222## Usage
2323
24- Search for the [ official API Documentation] ( https://developers.lexoffice.io/docs/ ) .
24+ Search for the [ official API Documentation] ( https://developers.lexoffice.io/docs/ ) .
2525You need an [ API Key] ( https://app.lexoffice.de/addons/public-api ) for that.
2626
2727### Basic
2828``` php
2929// store keys in .env file
30- $apiKey = getenv('LEXOFFICE_API_KEY');
30+ $apiKey = getenv('LEXOFFICE_API_KEY');
3131
32- // in this example we are using guzzlehttp/guzzle package, it can be any PSR-18 HTTP Client
32+ // in this example we are using guzzlehttp/guzzle package, it can be any PSR-18 HTTP Client
3333// see: https://packagist.org/providers/psr/http-client-implementation
3434$httpClient = \GuzzleHttp\Client();
3535$api = new \Sysix\LexOffice\Api($apiKey, $httpClient);
3636```
3737
3838### Optimize your HTTP Client
3939
40- This library only prepares the ` \Psr\Http\Message\RequestInterface ` for the HTTP Client and returns its Response.
41- There are almost no error checks, no caching and no rate limiting. Your PSR-18 HTTP Client should come with a way to deal with it.
40+ This library only prepares the ` \Psr\Http\Message\RequestInterface ` for the HTTP Client and returns its Response.
41+ There are almost no error checks, no caching and no rate limiting. Your PSR-18 HTTP Client should come with a way to deal with it.
4242
4343Here is a example with ` guzzlehttp/guzzle ` , ` kevinrob/guzzle-cache-middleware ` and ` spatie/guzzle-rate-limiter-middleware ` :
4444
4545``` php
46- $apiKey = getenv('LEXOFFICE_API_KEY');
46+ $apiKey = getenv('LEXOFFICE_API_KEY');
4747
4848$stack = \GuzzleHttp\HandlerStack::create();
4949$stack->push(new \Kevinrob\GuzzleCache\CacheMiddleware(), 'cache');
@@ -72,7 +72,7 @@ $client->type = 'PRODUCT';
7272
7373
7474// get a page
75- $response = $client->getPage(0);
75+ $response = $client->getPage(0);
7676
7777// other methods
7878$response = $client->get($entityId);
@@ -96,7 +96,7 @@ $client->customer = true;
9696$client->vendor = false;
9797
9898// get a page
99- $response = $client->getPage(0);
99+ $response = $client->getPage(0);
100100
101101// other methods
102102$response = $client->get($entityId);
@@ -118,9 +118,13 @@ $response = $api->creditNote()->create($data);
118118$response = $api->creditNote()->create($data, true); // finalized
119119$response = $api->creditNote()->pursue($precedingSalesVoucherId, $data);
120120$response = $api->creditNote()->pursue($precedingSalesVoucherId, $data, true); // finalized
121+ $response = $api->creditNote()->file($entityId); // get file content
122+ $response = $api->creditNote()->file($entityId, 'application/xml'); // as XRechnung
123+
124+ // deprecated methods:
121125$response = $api->creditNote()->document($entityId); // get document ID
122126$response = $api->creditNote()->document($entityId, true); // get file content
123- $response = $api->creditNote()->document($entityId, true, 'image/* '); // accept only images
127+ $response = $api->creditNote()->document($entityId, true, 'application/xml '); // as XRechnung
124128```
125129
126130### Deliverys Notes Endpoint
@@ -129,28 +133,36 @@ $voucherList = $api->deliveryNote()->getVoucherListClient(); // see VoucherlistC
129133$response = $api->deliveryNote()->get($entityId);
130134$response = $api->deliveryNote()->create($data);
131135$response = $api->deliveryNote()->pursue($precedingSalesVoucherId, $data);
136+ $response = $api->deliveryNote()->file($entityId); // get file content
137+
138+ // deprecated methods:
132139$response = $api->deliveryNote()->document($entityId); // get document ID
133140$response = $api->deliveryNote()->document($entityId, true); // get file content
134- $response = $api->deliveryNote()->document($entityId, true, 'image/*'); // accept only images
135141```
136142
137143### Down Payment Invoices Endpoint
138144``` php
139145$voucherList = $api->downPaymentInvoice()->getVoucherListClient(); // see VoucherlistClient Documentation
140146$response = $api->downPaymentInvoice()->get($entityId);
141147$response = $api->downPaymentInvoice()->create($data);
148+ $response = $api->downPaymentInvoice()->file($entityId); // get file content
149+ $response = $api->downPaymentInvoice()->file($entityId, 'application/xml'); // as XRechnung
150+
151+ // deprecated methods:
142152$response = $api->downPaymentInvoice()->document($entityId); // get document ID
143153$response = $api->downPaymentInvoice()->document($entityId, true); // get file content
144- $response = $api->downPaymentInvoice()->document($entityId, true, 'image/* '); // accept only images
154+ $response = $api->downPaymentInvoice()->document($entityId, true, 'application/xml '); // as XRechnung
145155```
146156
147157### Dunnings Endpoint
148158``` php
149159$response = $api->dunning()->get($entityId);
150160$response = $api->dunning()->pursue($precedingSalesVoucherId, $data);
161+ $response = $api->dunning()->file($entityId); // get file content
162+
163+ // deprecated methods:
151164$response = $api->dunning()->document($entityId); // get document ID
152165$response = $api->dunning()->document($entityId, true); // get file content
153- $response = $api->dunning()->document($entityId, true, 'image/*'); // accept only images
154166```
155167
156168### Event Subscriptions Endpooint
@@ -177,10 +189,13 @@ $response = $api->invoice()->create($data);
177189$response = $api->invoice()->create($data, true); // finalized
178190$response = $api->invoice()->pursue($precedingSalesVoucherId, $data);
179191$response = $api->invoice()->pursue($precedingSalesVoucherId, $data, true); // finalized
192+ $response = $api->invoice()->file($entityId); // get file content
193+ $response = $api->invoice()->file($entityId, 'application/xml'); // as XRechnung
194+
195+ // deprecated methods:
180196$response = $api->invoice()->document($entityId); // get document ID
181197$response = $api->invoice()->document($entityId, true); // get file content
182- $response = $api->invoice()->document($entityId, true, 'image/*'); // accept only images
183- $response = $api->invoice()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
198+ $response = $api->invoice()->document($entityId, true, 'application/xml'); // as XRechung XML File
184199```
185200
186201### Order Confirmation Endpoint
@@ -189,9 +204,11 @@ $voucherList = $api->orderConfirmation()->getVoucherListClient(); // see Voucher
189204$response = $api->orderConfirmation()->get($entityId);
190205$response = $api->orderConfirmation()->create($data);
191206$response = $api->orderConfirmation()->pursue($precedingSalesVoucherId, $data);
207+ $response = $api->orderConfirmation()->file($entityId); // get file content
208+
209+ // deprecated methods:
192210$response = $api->orderConfirmation()->document($entityId); // get document ID
193211$response = $api->orderConfirmation()->document($entityId, true); // get file content
194- $response = $api->orderConfirmation()->document($entityId, true, 'image/*'); // accept only images
195212```
196213
197214### Payment Endpoint
@@ -225,9 +242,11 @@ $voucherList = $api->quotation()->getVoucherListClient(); // see VoucherlistClie
225242$response = $api->quotation()->get($entityId);
226243$response = $api->quotation()->create($data);
227244$response = $api->quotation()->create($data, true); // finalized
245+ $response = $api->quotation()->file($entityId); // get file content
246+
247+ // deprecated methods:
228248$response = $api->quotation()->document($entityId); // get document ID
229249$response = $api->quotation()->document($entityId, true); // get file content
230- $response = $api->quotation()->document($entityId, true, 'image/*'); // accept only images
231250```
232251
233252### Recurring Templates Endpoint
@@ -252,10 +271,6 @@ $response = $api->recurringTemplate()->get($entityId);
252271$response = $api->voucher()->get($entityId);
253272$response = $api->voucher()->create($data);
254273$response = $api->voucher()->update($entityId, $data);
255- $response = $api->voucher()->document($entityId); // get document ID
256- $response = $api->voucher()->document($entityId, true); // get file content
257- $response = $api->voucher()->document($entityId, true, 'image/*'); // accept only images
258- $response = $api->voucher()->document($entityId, true, 'application/xml'); // get XRechung XML File (if possible)
259274$response = $api->voucher()->upload($entitiyId, $filepath);
260275```
261276
@@ -304,7 +319,7 @@ $client->updatedDateTo = new \DateTime('2023-12-01');
304319$response = $client->getPage(0);
305320```
306321
307- ## Utils
322+ ## Utils
308323
309324### get JSON from Success and Error Response
310325
0 commit comments