fbarachino / kalliopepbx
Helper to consume Kalliope's RestAPI
1.0.1
2025-05-08 08:47 UTC
Requires
- guzzlehttp/guzzle: ^7.9
README
Package per Laravel per utilizzare le RestAPI del Kalliope PBX
Usage
To use this package for laravel, follow the steps below:
-
Install the package via Composer:
composer require fbarachino/kalliopepbx
-
Publish the config file:
php artisan vendor:publish --tag=kalliopepbx-config
and edit it with correct values.
-
Initialize and configure the library as needed (for example):
... use Illuminate\Support\Facades\Storage; use fbarachino\kalliopepbx\KalliopePbx; class RestApiCall { public static function getSerialNumber() { $kalliope = new KalliopePbx(); $response = $kalliope->sendRequest('rest/dashboard/serialNumber','GET'); return $response; } // remeber to execute 'php artisan storage:link' public static function backup($filename, $description) { $kalliope = new KalliopePbx(); $firmware = $kalliope->sendRequest('/rest/dashboard/firmwareVersion','GET'); $data = [ 'backup'=> [ 'filename' => $filename, 'comment' => $description ], ]; $response = json_decode($kalliope->sendRequest('rest/backup/create/'.$firmware,'POST',$data); return Storage::disk('local')->put('/public/backup/kalliope/'.$filename.'.bak', $response); } } ...
-
You can use the helper as:
$kalliope->sendRequest($url,$method,$data);
Where
$urlis the URL of the API request,$methodis the method (GET,POST,PUT,PATCH,DELETE), and$datais the array of fields.
From version 1.0.1 you can also instantiate directly if you don't want to use the config/kalliopepbx.php file:
... $kalliope = new KalliopePbx($address,$port,$protocol,$username,$password); ...