|
| 1 | +# 💾 Lexoffice PHP API |
| 2 | + |
| 3 | +<div align="center"> |
| 4 | + <a href="https://www.exbil.net"><img src="https://vweb01.exbil.net/images/logos/ylx31Wjx3YY.png" width="546" alt="discord.js" /></a> |
| 5 | +</div> |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +# Getting Started |
| 12 | +### Requirements |
| 13 | +* [**PHP 7.4+**](https://www.php.net/downloads.php) |
| 14 | +* Extensions: [Composer](https://getcomposer.org/), [PHP-JSON](https://www.php.net/manual/en/book.json.php) |
| 15 | + |
| 16 | +# ⚒️ Install |
| 17 | +```bash |
| 18 | +composer require exbil/lexoffice-php-api |
| 19 | +``` |
| 20 | + |
| 21 | +# 📑 Usage |
| 22 | + |
| 23 | +Search for the official API Documentation [here](https://developers.lexoffice.io/docs/). |
| 24 | +You need an [API Key](https://app.lexoffice.de/addons/public-api) for that. |
| 25 | + |
| 26 | +### 🗃️ Basic |
| 27 | + |
| 28 | +```php |
| 29 | +$apiKey = getenv('LEX_OFFICE_API_KEY'); // store keys in .env file |
| 30 | +$api = new \exbil\LexOffice\LexOfficeClient($apiKey); |
| 31 | +``` |
| 32 | + |
| 33 | +### 🗃️ set cache |
| 34 | + |
| 35 | +```php |
| 36 | +// can be any PSR-6 compatibly cache handler |
| 37 | +// in this example we are using symfony/cache |
| 38 | +$cacheInterface = new \Symfony\Component\Cache\Adapter\FilesystemAdapter( |
| 39 | + 'lexoffice', |
| 40 | + 3600, |
| 41 | + __DIR__ . '/cache' |
| 42 | +); |
| 43 | + |
| 44 | +$api->setCacheInterface($cacheInterface); |
| 45 | +``` |
| 46 | + |
| 47 | +### 🔚 Contact Endpoint |
| 48 | + |
| 49 | +```php |
| 50 | + |
| 51 | +// get a page |
| 52 | +/** @var \exbil\LexOffice\LexOfficeClient $api */ |
| 53 | +$client = $api->contact(); |
| 54 | + |
| 55 | +$client->size = 100; |
| 56 | +$client->sortDirection = 'ASC'; |
| 57 | +$client->sortProperty = 'name'; |
| 58 | + |
| 59 | +// get a page |
| 60 | +$response = $client->getPage(0); |
| 61 | + |
| 62 | +//get all |
| 63 | +$response = $client->getAll(); |
| 64 | + |
| 65 | +// other methods |
| 66 | +$response = $client->get($entityId); |
| 67 | +$response = $client->create($data); |
| 68 | +``` |
| 69 | + |
| 70 | +### 🗺️ Country Endpoint |
| 71 | +```php |
| 72 | +$response = $api->country()->getAll(); |
| 73 | +``` |
| 74 | + |
| 75 | +### 🔚 Invoices Endpoint |
| 76 | +```php |
| 77 | +$response = $api->invoice()->getAll(); |
| 78 | +$response = $api->invoice()->get($entityId); |
| 79 | +$response = $api->invoice()->create($data); |
| 80 | +$response = $api->invoice()->document($entityId); // get document ID |
| 81 | +$response = $api->invoice()->document($entityId, true); // get file content |
| 82 | +``` |
| 83 | + |
| 84 | +### 🔚 Down Payment Invoices Endpoint |
| 85 | +```php |
| 86 | +$response = $api->downPaymentInvoice()->getAll(); |
| 87 | +$response = $api->downPaymentInvoice()->get($entityId); |
| 88 | +$response = $api->downPaymentInvoice()->create($data); |
| 89 | +$response = $api->downPaymentInvoice()->document($entityId); // get document ID |
| 90 | +$response = $api->downPaymentInvoice()->document($entityId, true); // get file content |
| 91 | +``` |
| 92 | + |
| 93 | +### 💵 Order Confirmation Endpoint |
| 94 | +```php |
| 95 | +$response = $api->orderConfirmation()->getAll(); |
| 96 | +$response = $api->orderConfirmation()->get($entityId); |
| 97 | +$response = $api->orderConfirmation()->create($data); |
| 98 | +$response = $api->orderConfirmation()->document($entityId); // get document ID |
| 99 | +$response = $api->orderConfirmation()->document($entityId, true); // get file content |
| 100 | +``` |
| 101 | + |
| 102 | +### 📃 Quotation Endpoint |
| 103 | +```php |
| 104 | +$response = $api->quotation()->getAll(); |
| 105 | +$response = $api->quotation()->get($entityId); |
| 106 | +$response = $api->quotation()->create($data); |
| 107 | +$response = $api->quotation()->document($entityId); // get document ID |
| 108 | +$response = $api->quotation()->document($entityId, true); // get file content |
| 109 | +``` |
| 110 | + |
| 111 | +### 📄 Voucher Endpoint |
| 112 | +```php |
| 113 | +$response = $api->voucher()->getAll(); |
| 114 | +$response = $api->voucher()->get($entityId); |
| 115 | +$response = $api->voucher()->create($data); |
| 116 | +$response = $api->voucher()->update($entityId, $data); |
| 117 | +$response = $api->voucher()->document($entityId); // get document ID |
| 118 | +$response = $api->voucher()->document($entityId, true); // get file content |
| 119 | +``` |
| 120 | + |
| 121 | + |
| 122 | +### 💵 Credit Notes Endpoint |
| 123 | +```php |
| 124 | +$response = $api->creditNote()->getAll(); |
| 125 | +$response = $api->creditNote()->get($entityId); |
| 126 | +$response = $api->creditNote()->create($data); |
| 127 | +$response = $api->creditNote()->document($entityId); // get document ID |
| 128 | +$response = $api->creditNote()->document($entityId, true); // get file content |
| 129 | +``` |
| 130 | + |
| 131 | +### 💵 Payment Endpoint |
| 132 | +```php |
| 133 | +$response = $api->payment()->get($entityId); |
| 134 | +``` |
| 135 | + |
| 136 | +### 💵 Payment Conditions Endpoint |
| 137 | +```php |
| 138 | +$response = $api->paymentCondition()->getAll(); |
| 139 | +``` |
| 140 | + |
| 141 | +### 🗂️ Posting Categories Endpoint |
| 142 | +```php |
| 143 | +$response = $api->postingCategory()->getAll(); |
| 144 | +``` |
| 145 | + |
| 146 | +### 🧑🏻 Profile Endpoint |
| 147 | +```php |
| 148 | +$response = $api->profile()->get(); |
| 149 | +``` |
| 150 | + |
| 151 | +### 📜 Recurring Templates Endpoint |
| 152 | +```php |
| 153 | + |
| 154 | +// get single entitiy |
| 155 | +$response = $api->recurringTemplate()->get($entityId); |
| 156 | + |
| 157 | +// use pagination |
| 158 | +$client = $api->recurringTemplate(); |
| 159 | +$client->size = 100; |
| 160 | + |
| 161 | + |
| 162 | +// get a page |
| 163 | +$response = $client->getPage(0); |
| 164 | + |
| 165 | +//get all |
| 166 | +$response = $client->getAll(); |
| 167 | +``` |
| 168 | + |
| 169 | + |
| 170 | +### 🔚 Voucherlist Endpoint |
| 171 | +```php |
| 172 | +$client = $api->voucherlist(); |
| 173 | + |
| 174 | +$client->size = 100; |
| 175 | +$client->sortDirection = 'DESC'; |
| 176 | +$client->sortColumn = 'voucherNumber'; |
| 177 | +$client->types = [ |
| 178 | + 'salesinvoice', |
| 179 | + 'salescreditnote', |
| 180 | + 'purchaseinvoice', |
| 181 | + 'purchasecreditnote', |
| 182 | + 'invoice', |
| 183 | + 'downpaymentinvoice', |
| 184 | + 'creditnote', |
| 185 | + 'orderconfirmation', |
| 186 | + 'quotation' |
| 187 | +]; |
| 188 | +$client->statuses = [ |
| 189 | + 'draft', |
| 190 | + 'open', |
| 191 | + 'paid', |
| 192 | + 'paidoff', |
| 193 | + 'voided', |
| 194 | + //'overdue', overdue can only be fetched alone |
| 195 | + 'accepted', |
| 196 | + 'rejected' |
| 197 | +]; |
| 198 | + |
| 199 | +// get everything what we can, not recommend: |
| 200 | +//$client->setToEverything() |
| 201 | + |
| 202 | +// get a page |
| 203 | +$response = $client->getPage(0); |
| 204 | + |
| 205 | +//get all |
| 206 | +$response = $client->getAll(); |
| 207 | +``` |
| 208 | + |
| 209 | +### 📁 File Endpoint |
| 210 | +```php |
| 211 | +$response = $api->file()->upload($filePath, $voucherType); |
| 212 | +$response = $api->file()->get($entityId); |
| 213 | +``` |
| 214 | + |
| 215 | + |
| 216 | +### ⚒️ Get JSON from Response |
| 217 | + |
| 218 | +```php |
| 219 | +$json = $api->*()->getAsJson($response); |
| 220 | +``` |
0 commit comments