Files
huangjingfen/pro_v3.5.1/crmeb/services/wechat/client/work/ContactWayClient.php
panchengyong c1e74d8e68 chore(php): 统一 ScottPan 文件头与注释域名替换
- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明

Made-with: Cursor
2026-03-29 11:22:58 +08:00

126 lines
4.0 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
// +----------------------------------------------------------------------
// | Author: ScottPan Team
// +----------------------------------------------------------------------
namespace crmeb\services\wechat\client\work;
use crmeb\services\wechat\client\BaseClient;
use EasyWeChat\Kernel\HttpClient\Response;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\ResponseInterface;
/**
* 联系客服
* Class ContactWayClient
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/19
* @package crmeb\services\wechat\client\work
*/
class ContactWayClient extends BaseClient
{
/**
* 配置客户联系「联系我」方式.
* @param int $type
* @param int $scene
* @param array $config
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function create(int $type, int $scene, array $config = []): ResponseInterface|Response
{
$params = array_merge([
'type' => $type,
'scene' => $scene,
], $config);
return $this->api->postJson('cgi-bin/externalcontact/add_contact_way', $params);
}
/**
* 更新企业已配置的「联系我」方式.
* @param string $configId
* @param array $config
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function update(string $configId, array $config = []): ResponseInterface|Response
{
$params = array_merge([
'config_id' => $configId,
], $config);
return $this->api->postJson('cgi-bin/externalcontact/update_contact_way', $params);
}
/**
* 删除企业已配置的「联系我」方式.
* @param string $configId
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function delete(string $configId): ResponseInterface|Response
{
return $this->api->postJson('cgi-bin/externalcontact/del_contact_way', [
'config_id' => $configId,
]);
}
/**
* 获取企业已配置的「联系我」列表注意该接口仅可获取2021年7月10日以后创建的「联系我」
* @param string $cursor 分页查询使用的游标,为上次请求返回的 next_cursor
* @param int $limit 每次查询的分页大小默认为100条最多支持1000条
* @param int|null $startTime 「联系我」创建起始时间戳, 不传默认为90天前
* @param int|null $endTime 「联系我」创建结束时间戳, 不传默认为当前时间
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function list(string $cursor = '', int $limit = 100, int $startTime = null, int $endTime = null): ResponseInterface|Response
{
$data = [
'cursor' => $cursor,
'limit' => $limit,
];
if ($startTime) {
$data['start_time'] = $startTime;
}
if ($endTime) {
$data['end_time'] = $endTime;
}
return $this->api->postJson('cgi-bin/externalcontact/list_contact_way', $data);
}
/**
* 结束临时会话
* @param string $userId 企业成员的user_id
* @param string $externalUserId 客户的外部联系人user_id
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function closeTempChat(string $userId, string $externalUserId): ResponseInterface|Response
{
return $this->api->postJson('cgi-bin/externalcontact/close_temp_chat', [
'userid' => $userId,
'external_userid' => $externalUserId
]);
}
}