机器人API添加根据邮箱获取用户信息和批量获取用户信息的接口
This commit is contained in:
@@ -1975,6 +1975,7 @@ public class Main {
|
||||
createRobot.setName(robotId);
|
||||
createRobot.setDisplayName("机器人");
|
||||
createRobot.setOwner("userId1");
|
||||
createRobot.setEmail("[email protected]");
|
||||
createRobot.setSecret(robotSecret);
|
||||
createRobot.setCallback("http://127.0.0.1:8883/robot/recvmsg");
|
||||
IMResult<OutputCreateRobot> resultCreateRobot = UserAdmin.createRobot(createRobot);
|
||||
@@ -2134,6 +2135,21 @@ public class Main {
|
||||
System.out.println("robot get user info by name failure");
|
||||
}
|
||||
|
||||
//测试机器人通过邮箱获取用户信息
|
||||
IMResult<OutputUserInfoList> resultRobotGetUserInfoByEmail = robotService.getUserInfoByEmail("[email protected]");
|
||||
if (resultRobotGetUserInfoByEmail != null && resultRobotGetUserInfoByEmail.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot get user info by email success");
|
||||
} else {
|
||||
System.out.println("robot get user info by email failure");
|
||||
}
|
||||
|
||||
IMResult<OutputUserInfoList> userInfoListIMResult = robotService.getBatchUsers(Arrays.asList("userId1", "userId2"));
|
||||
if (userInfoListIMResult != null && userInfoListIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
System.out.println("robot get batch user info by email success");
|
||||
} else {
|
||||
System.out.println("robot get batch user info by email failure");
|
||||
}
|
||||
|
||||
//创建群组信息,用于测试机器人群组管理功能
|
||||
String groupId = "robot_group" + System.currentTimeMillis();
|
||||
PojoGroupInfo groupInfo = new PojoGroupInfo();
|
||||
|
||||
@@ -192,6 +192,30 @@ public class RobotService implements Closeable {
|
||||
return robotHttpUtils.httpJsonPost(path, getUserInfo, InputOutputUserInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据邮箱获取用户信息列表
|
||||
* @param email 邮箱地址
|
||||
* @return 用户信息列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public IMResult<OutputUserInfoList> getUserInfoByEmail(String email) throws Exception {
|
||||
String path = APIPath.Robot_User_Get_Email_Info;
|
||||
return robotHttpUtils.httpJsonPost(path, email, OutputUserInfoList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取用户信息
|
||||
* @param userIds 用户ID列表
|
||||
* @return 用户信息列表
|
||||
* @throws Exception 请求失败时抛出异常
|
||||
*/
|
||||
public IMResult<OutputUserInfoList> getBatchUsers(List<String> userIds) throws Exception {
|
||||
String path = APIPath.Robot_User_Batch_Get_Infos;
|
||||
InputStringList input = new InputStringList();
|
||||
input.setList(userIds);
|
||||
return robotHttpUtils.httpJsonPost(path, input, OutputUserInfoList.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置机器人消息回调地址
|
||||
* @param url 回调地址
|
||||
|
||||
Reference in New Issue
Block a user