Files
toolbox/app/Clients/MonoClient.php
T

48 lines
1.1 KiB
PHP

<?php
namespace App\Clients;
use Illuminate\Support\Facades\Http;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\Response;
class MonoClient
{
private string $baseUrl;
private PendingRequest $http;
public function __construct()
{
$this->baseUrl = config('services.mono.url');
$this->http = Http::timeout(config('services.mono.timeout', 30))
->withoutVerifying();
}
/**
* 测试连接
*/
public function testConnection(): Response
{
return $this->http->get($this->baseUrl . '/health');
}
/**
* 更新消息分发状态
*/
public function updateDispatch(array $data): Response
{
return $this->http->post($this->baseUrl . '/rpc/datadispatch/message/update-dispatch', $data);
}
/**
* 手动消费指定消息(由mono从CRM获取消息并进行分发)
*/
public function consumeMessage(string $msgId): Response
{
return $this->http->post($this->baseUrl . '/rpc/datadispatch/message/consume', [
'msg_id' => $msgId,
]);
}
}