222 lines
6.3 KiB
PHP
Executable File
222 lines
6.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace support\OpenImSdk\Api;
|
|
|
|
use support\OpenImSdk\Core\Url;
|
|
use support\OpenImSdk\Core\Utils;
|
|
|
|
class User
|
|
{
|
|
/**
|
|
* 获取用户列表
|
|
* @param int $pagination 页码
|
|
* @param int $showNumber 每页数量
|
|
* @return array
|
|
*/
|
|
public function getUsers(int $pagination = 1, int $showNumber = 20): array
|
|
{
|
|
$data = [
|
|
'pagination' => [
|
|
'pageNumber' => $pagination,
|
|
'showNumber' => $showNumber
|
|
]
|
|
];
|
|
return Utils::send(Url::$getUsers, $data);
|
|
}
|
|
|
|
/**
|
|
* 获取用户在线状态
|
|
* @param array $userIDList 用户ID列表
|
|
* @return array
|
|
*/
|
|
public function getUsersOnlineStatus(array $userIDList): array
|
|
{
|
|
return Utils::send(Url::$getUsersOnlineStatus, ['userIDList' => $userIDList]);
|
|
}
|
|
|
|
/**
|
|
* 获取用户在线token详情
|
|
* @param array $userIDList 用户ID列表
|
|
* @return array
|
|
*/
|
|
public function getUsersOnlineTokenDetail(array $userIDList): array
|
|
{
|
|
return Utils::send(Url::$getUsersOnlineTokenDetail, ['userIDList' => $userIDList]);
|
|
}
|
|
|
|
/**
|
|
* 获取订阅用户状态
|
|
* @return array
|
|
*/
|
|
public function getSubscribeUsersStatus(): array
|
|
{
|
|
return Utils::send(Url::$getSubscribeUsersStatus, []);
|
|
}
|
|
|
|
/**
|
|
* 订阅用户状态
|
|
* @param array $userIDList 用户ID列表
|
|
* @return array
|
|
*/
|
|
public function subscribeUsersStatus(array $userIDList): array
|
|
{
|
|
return Utils::send(Url::$subscribeUsersStatus, ['userIDList' => $userIDList]);
|
|
}
|
|
|
|
/**
|
|
* 设置全局免打扰
|
|
* @param int $globalRecvMsgOpt 全局消息接收选项
|
|
* @return array
|
|
*/
|
|
public function setGlobalMsgRecvOpt(int $globalRecvMsgOpt): array
|
|
{
|
|
return Utils::send(Url::$setGlobalMsgRecvOpt, ['globalRecvMsgOpt' => $globalRecvMsgOpt]);
|
|
}
|
|
|
|
/**
|
|
* 修改用户信息
|
|
* @param string $userID 用户ID
|
|
* @param array $data 用户信息
|
|
* @return array
|
|
*/
|
|
public function updateUserInfo(string $userID, array $data): array|bool
|
|
{
|
|
$data = array_merge(['userID' => $userID], $data);
|
|
$data = [
|
|
'userInfo' => $data
|
|
];
|
|
return Utils::send(Url::$updateUserInfo, $data);
|
|
}
|
|
|
|
/**
|
|
* 搜索通知账号
|
|
* @param string $keyword 搜索关键词
|
|
* @param int $pagination 页码
|
|
* @param int $showNumber 每页数量
|
|
* @return array
|
|
*/
|
|
public function searchNotificationAccount(string $keyword, int $pagination = 1, int $showNumber = 20): array
|
|
{
|
|
$data = [
|
|
'keyword' => $keyword,
|
|
'pagination' => [
|
|
'pageNumber' => $pagination,
|
|
'showNumber' => $showNumber
|
|
]
|
|
];
|
|
return Utils::send(Url::$searchNotificationAccount, $data);
|
|
}
|
|
|
|
/**
|
|
* 添加通知账号
|
|
* @param string $userID 用户ID
|
|
* @param string $nickname 昵称
|
|
* @param string $faceURL 头像
|
|
* @param \support\OpenImSdk\Enum\appMangerLevel $appMangerLevel 应用管理等级
|
|
* @return array
|
|
*/
|
|
public function addNotificationAccount(string $userID, string $nickname = '', string $faceURL = '', \support\OpenImSdk\Enum\appMangerLevel $appMangerLevel = \support\OpenImSdk\Enum\appMangerLevel::Notify): array
|
|
{
|
|
$data = [
|
|
'userID' => $userID,
|
|
'nickname' => $nickname,
|
|
'faceURL' => $faceURL,
|
|
'appMangerLevel' => $appMangerLevel->value,
|
|
];
|
|
return Utils::send(Url::$addNotificationAccount, $data);
|
|
}
|
|
|
|
/**
|
|
* 更新通知账号
|
|
* @param string $userID 用户ID
|
|
* @param string $nickname 昵称
|
|
* @param string $faceURL 头像
|
|
* @return array
|
|
*/
|
|
public function updateNotificationAccount(string $userID, string $nickname = '', string $faceURL = ''): array
|
|
{
|
|
// 获取管理员token
|
|
$data = [
|
|
'userID' => $userID,
|
|
'nickname' => $nickname,
|
|
'faceURL' => $faceURL
|
|
];
|
|
return Utils::send(Url::$updateNotificationAccount, $data);
|
|
}
|
|
|
|
/**
|
|
* 检查列表账户注册状态
|
|
* @param array $checkUserIDList 用户ID列表
|
|
* @return array
|
|
*/
|
|
public function accountCheck(array $checkUserIDList): array
|
|
{
|
|
return Utils::send(Url::$accountCheck, ['checkUserIDList' => $checkUserIDList]);
|
|
}
|
|
|
|
/**
|
|
* 获取所有用户uid列表
|
|
* @return array
|
|
*/
|
|
public function getAllUsersUid($page=1,$limit=100): array
|
|
{
|
|
return Utils::send(Url::$getAllUsersUid, ['pagination'=>['pageNumber'=>$page,"showNumber"=>$limit]]);
|
|
}
|
|
|
|
/**
|
|
* 获取自己的信息
|
|
* @param string $userID 用户ID
|
|
* @return array
|
|
*/
|
|
public function getSelfUserInfo(string $userID): array
|
|
{
|
|
return Utils::send(Url::$getSelfUserInfo, ['userID' => $userID]);
|
|
}
|
|
|
|
/**
|
|
* 获取用户信息
|
|
* @param array $userIDList 用户ID列表
|
|
* @return array
|
|
*/
|
|
public function getUsersInfo(array $userIDList): array
|
|
{
|
|
return Utils::send(Url::$getUsersInfo, ['userIDList' => $userIDList]);
|
|
}
|
|
|
|
//Header
|
|
//
|
|
//Header Name Example Value Required Type Description
|
|
//operationID 1646445464564 Required string Used for global traceability, suggested as a unique timestamp per request
|
|
//token eyJhbxxxx3Xs Required string Admin token
|
|
|
|
//Field Name Required Type Description
|
|
//users Required array List of users
|
|
//users.userID Required string User ID
|
|
//users.nickname Required string User nickname
|
|
//users.faceURL Required string User avatar URL
|
|
/**
|
|
* 用户注册
|
|
* @param string $userID 用户ID
|
|
* @param string $nickname 昵称
|
|
* @param string $faceURL 头像地址
|
|
* @return array
|
|
*/
|
|
public function userRegister(string|array $userID, string $nickname = '', string $faceURL = ''): array|bool
|
|
{
|
|
if(is_array($userID)){
|
|
$data['users'] = $userID;
|
|
}else{
|
|
$data = [
|
|
'users' => [
|
|
[
|
|
'userID' => $userID,
|
|
'nickname' => $nickname,
|
|
'faceURL' => $faceURL
|
|
]
|
|
]
|
|
];
|
|
}
|
|
return Utils::send(Url::$userRegister, $data);
|
|
}
|
|
}
|