Files
huangjingfen/pro_v3.5.1/crmeb/services/wechat/client/work/UserClient.php
apple 78de918c37 Initial commit: queue workspace
Made-with: Cursor
2026-03-21 02:55:24 +08:00

87 lines
2.6 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
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
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 UserClient
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/18
* @package crmeb\services\wechat\client\work
*/
class UserClient extends BaseClient
{
/**
* 获取部门成员详细信息
* @param int $departmentId
* @param bool $fetchChild
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function getDetailedDepartmentUsers(int $departmentId, bool $fetchChild = false): ResponseInterface|Response
{
$params = [
'department_id' => $departmentId,
'fetch_child' => (int)$fetchChild,
];
return $this->api->get('cgi-bin/user/list', $params);
}
/**
* 获取通讯录成员详情
* @param string $userId
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function get(string $userId): ResponseInterface|Response
{
return $this->api->get('cgi-bin/user/get', ['userid' => $userId]);
}
/**
* userid转openid
* @param string $userId
* @param int|null $agentId
* @return Response|ResponseInterface
* @throws TransportExceptionInterface
* @author 等风来
* @email 136327134@qq.com
* @date 2023/9/15
*/
public function userIdToOpenid(string $userId, int $agentId = null): ResponseInterface|Response
{
$params = [
'userid' => $userId,
'agentid' => $agentId,
];
return $this->api->postJson('cgi-bin/user/convert_to_openid', $params);
}
}