hsyir/simotel-laravel-connect

此包的最新版本(1.2.2)没有提供许可信息。

所有使 Simotel 与 Laravel 保持连接所需的内容

1.2.2 2020-09-21 06:52 UTC

This package is auto-updated.

Last update: 2024-09-14 12:31:26 UTC


README

laravel 与 Simotel 的关联包

Scrutinizer Code Quality Build Status Code Intelligence Status

使用 Laravel 连接到 Simotel

安装

使用 Composer 和 Laravel 6 及以上版本,以下命令安装此包:

composer require hsyir/simotel-laravel-connect

然后执行以下命令将创建配置文件:

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

与 Simotel 兼容

Simotel Api

Simotel Api 是 Simotel 软件的一个强大功能,通过此 Api 可以远程通过 Laravel 强大的框架执行一些在 Simotel 上的操作。

连接到 Simotel

要定义 Simotel 服务器地址和登录信息,请修改配置文件 simotel.php 中的以下值:

"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)

Simotel 事件 Api

Simotel 事件 Api (SEA) 是 Simotel 的发布服务。此包允许通过 Laravel 的 Events 和 Listeners 功能使用此服务。要使用 SEA 中的事件,您可以在 Laravel 的 EventServiceProvider 中使用以下类。

"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,

示例 Listener

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

apiData 属性包含 Simotel 发送的信息,这些信息被发送到 Listener。

示例 Controller

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());
    }
}

智能 Api

要使用 Simotel 软件的特殊功能在 Laravel 框架中,首先创建一个类,如下所示。要使用包中的预定义命令,请使用名为 SmartApiCommands 的 Trait。

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)  

在配置文件 simotel.php 中设置创建的类的值。

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

示例 Controller

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);
    }
}

许可