PHP code example of hsyir / simotel-laravel-connect

1. Go to this page and download the library: Download hsyir/simotel-laravel-connect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hsyir / simotel-laravel-connect example snippets



"simotelApi" => [
        "apiUrl" => env("SIMOTEL_API_SERVER", "http://127.0.0.1/api/v1/"),
        "user" => env("SIMOTEL_API_USER", "user"),
        "pass" => env("SIMOTEL_API_PASS", "pass"),
    ],


$simotelApi = new \Hsy\SimotelConnect\SimotelApi();
$result = $simotelApi->pauseInQueue($queue, $agent);

if(!$result)
    $errorMessage = $simotelApi->getMessage(); 

boolean addToQueue($queue, $source, $agent, $penalty = 0)
boolean removeFromQueue($queue, $agent)
boolean pauseInQueue($queue, $agent)
boolean resumeInQueue($queue, $agent)


"Cdr" => \Hsy\SimotelConnect\Events\SimotelEventCdr::class,  
"NewState" => \Hsy\SimotelConnect\Events\SimotelEventNewState::class,  
"ExtenAdded" => \Hsy\SimotelConnect\Events\SimotelEventExtenAdded::class,  
"ExtenRemoved" => \Hsy\SimotelConnect\Events\SimotelEventExtenRemoved::class,  
"IncomingCall" => \Hsy\SimotelConnect\Events\SimotelEventIncomingCall::class,  
"OutGoingCall" => \Hsy\SimotelConnect\Events\SimotelEventOutgoingCall::class,  
"Transfer" => \Hsy\SimotelConnect\Events\SimotelEventTransfer::class,


namespace App\Listeners;  
  
class UpdateCallCdrData  
{        
   /**  
    * Handle the event. 
    * 
    * @param object $event  
    * @return void  
    */    	     
    public function handle($event)  
    {
      $cdrData = $event->apiData;  
      
      // 
      
    }
       
 }

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Hsy\SimotelConnect\SimotelEventApi;
use Illuminate\Http\Request;

class SeaController extends Controller
{
    public function dispatchEvent(Request $request)
    {
        $simotelEventApi = new  SimotelEventApi;
        $simotelEventApi->dispatchSimotelEvent($request->all());
    }
}


namespace App\Classes;  
         
use Hsy\SimotelConnect\SmartApiCommands;  
  
class SmartApiMethodsRepo  
{  
    use SmartApiCommands;  
  
    // نام متد باید مساوی با نام کامپوننت SmartApi در نقشه تماس سیموتل باشد.
    public function select_queue($apiData)  
    {  
        
        $this->cmdGetData("SelectQueue", 4, 2);  
        $this->cmdExit("1");  
            
        if(true)
            return $this->okResponse();  
        //else
            return $this->errorResponse();
    }
    
 }



cmdPlayAnnouncement($file)  
cmdPlayback($file)  
cmdExit($exit)  
cmdGetData($file,$timeout,$digitsCount)  
cmdSayDigit($number)  
cmdSayNumber($number)  
cmdSayClock($clock)  
cmdSayDate($date,$calender)  
cmdSayDuration($duration)  
cmdSetExten($exten)  
cmdSetLimitOnCall($seconds)  




 "smartApi" => [  
      "methodsRepositoryClass" => \App\Classes\SmartApiMethodsRepo::class,  
    ],



namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Hsy\SimotelConnect\SmartApi;
use Illuminate\Http\Request;

class SmartApiController extends Controller
{
    public function call(Request $request)
    {
        $smartApi = new SmartApi;
        $response = $smartApi->callApi($request->all());
        return response()->json($response);
    }
}



php artisan vendor:publish --provider=Hsyir\\SimotelConnect\\SimotelApiServiceProvider