dev-master
9999999-dev
The Requires
- guzzlehttp/guzzle ^6.2
- awelty/security dev-master
- php >=5.4.0
- symfony/options-resolver ^3.2
- symfony/serializer ^3.2
PHP SDK for https://fr.luminjo.com, (*1)
composer require luminjo/php-sdk:dev-master
A stable version will eventually be released one day..., (*2)
<?php use Luminjo\PhpSdk\Luminjo; $luminjo = new Luminjo($publicKey, $privateKey, $guzzleOptions = []);
<?php use Luminjo\PhpSdk\LuminjoException; // ... try { // eveything is ok $luminjo->auth()->verify(); } catch (LuminjoException $e) { $code = $e->getCode(); // see error handling $message = $e->getMessage(); // the PSR response can be retrieved $originalResponse = $e->getResponse(); }
<?php $response = $luminjo->ticket()->create([ // required fields 'from' => 'client@email.com', 'subject' => '$subject', 'content' => '$htmlContent', // optionnal 'url' => 'http://www.google.com', // a related url or whatever you want.. 'user_agent' => $userAgent, 'folder' => 'My folder', // a folder name, will be created if missing 'tags' => ['tag 1', 'tag 2'], // some tags 'files' => [ [ 'filename' => 'test avatar api.jpg', // display usage 'path' => 'path/to/file', // a fopen-able path ] ], 'extra_fields' => [ // values MUST be scalar 'a' => 'b', 'any' => 'key-value pair' ] ]); // 201 empty response $ticketUrl = $response->getHeader('Location');
<?php $tickets = $luminjo->ticket()->find([ // required fields 'email' => 'client@email.com', ]);
You wille receive an array response :, (*3)
Array ( [0] => stdClass Object ( [subject] => My ticket // can be null [url] => https://posao.luminjo.com/tickets/123 [type] => 1 // see "Ticket types" chapter ) )
<?php $questions = $luminjo->faq()->index([ // optionnal 'category' => $categoryId, ]);
Response :, (*4)
Array ( [0] => stdClass Object ( [id] => 1 [qustion] => "How change my password" [response] => "Seriously ?, (*5)
" // html content [highlight] => true / false ) )
<?php $categories = $luminjo->faq()->categories();
Response :, (*6)
Array ( [0] => stdClass Object ( [id] => 1 [name] => "My category" ) )
Tickets can be more than simple tickets, for example when you get a customer call. Remember, only tickets type 1 should be visible for a customer, other types are hidden. - ticket: 1 - call: 2 - meet: 3 - other: 4, (*7)
Every API call must be try catched to handle client errors. The LuminjoException contain the response, the error code and a message. The message is for the developper, the code can help you to show a proper error message to the end user., (*8)
<?php use Luminjo\PhpSdk\LuminjoException; // ... try { $response = $luminjo->whatever(); } catch (LuminjoException $e) { $code = $e->getCode(); $message = $e->getMessage(); $originalResponse = $e->getResponse(); }
Keep in mind that codes can be added in the future., (*9)
Current limitation is 60 requests per minutes., (*10)