Files
toolbox/app/Clients/MonoClient.php

48 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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,
]);
}
}