fbarachino/kalliopepbx

Helper to consume Kalliope's RestAPI

Maintainers

Package info

github.com/fbarachino/kalliopepbx

pkg:composer/fbarachino/kalliopepbx

Statistics

Installs: 23

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.1 2025-05-08 08:47 UTC

This package is auto-updated.

Last update: 2026-03-21 14:45:27 UTC


README

Package per Laravel per utilizzare le RestAPI del Kalliope PBX

Usage

To use this package for laravel, follow the steps below:

  1. Install the package via Composer:

    composer require fbarachino/kalliopepbx
  2. Publish the config file:

    php artisan vendor:publish --tag=kalliopepbx-config

    and edit it with correct values.

  3. 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);         
        } 
    
    }
    ...
  4. You can use the helper as:

    $kalliope->sendRequest($url,$method,$data);

    Where $url is the URL of the API request, $method is the method (GET,POST,PUT,PATCH,DELETE), and $data is 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);
...